Creating wpf feed at runtime

I am trying to bind a ribbon control for dynamic menus.

<ribbon:Ribbon>
   <ribbon:RibbonTab Header="Reports"
        ItemsSource="{Binding ReportMenus}"
        ItemTemplate="{StaticResource RibbonGroupDataTemplate}">
    </ribbon:RibbonTab>
    <ribbon:RibbonTab Header="Test">
     <ribbon:RibbonGroup Header="TestGROUP"
      ItemsSource="{Binding ReportMenus}"
      ItemTemplate="{StaticResource RibbonButtonDataTemplate}">
     </ribbon:RibbonGroup>
    </ribbon:RibbonTab>
</ribbon:Ribbon>

The top ribbon tab is my β€œreal” ribbontab. The bottom began as manually, that I test my theories with the help.

Here is the data I'm trying to use:

<Style TargetType="{x:Type ribbon:RibbonButton}">
   <Setter Property="Label"
           Value="{Binding ReportDisplayName}" />
</Style>

<DataTemplate x:Key="RibbonButtonDataTemplate">
   <ribbon:RibbonButton />
</DataTemplate>

This is my first attempt at a DataTemplate group:

<HierarchicalDataTemplate x:Key="RibbonGroupDataTemplate" DataType="{x:Type Ribbon:RibbonGroup}"
 ItemsSource="{Binding Converter={StaticResource DebugConverter}}"
 ItemTemplate="{StaticResource RibbonButtonDataTemplate}">
   <TextBlock Text="{Binding Path=ReportDisplayName}" />
</HierarchicalDataTemplate>

Then I tried to do this:

<DataTemplate x:Key="RibbonGroupDataTemplate">
  <ribbon:RibbonGroup ItemsSource="{Binding Converter={StaticResource DebugConverter}}"
          ItemTemplate="{StaticResource RibbonButtonDataTemplate}" />
</DataTemplate>

, . , , . , . , ribbongroup , . , HierarchicalDatatemplate. Datatemplate itemsource itemtemplate.

, RibbonGroup Dynamic RibbonButtons?


, , , .

: alt text

, , . alt text

xaml

<DataTemplate x:Key="RibbonButtonDataTemplate">
   <ribbon:RibbonButton />
</DataTemplate>

<HierarchicalDataTemplate x:Key="RibbonGroupDataTemplate"
                                  DataType="{x:Type ribbon:RibbonGroup}"
                                  ItemsSource="{Binding ReportsMenuCollection}"
                                  ItemTemplate="{StaticResource RibbonButtonDataTemplate}">
   <TextBlock Text="{Binding Path=ReportDisplayName}" />
</HierarchicalDataTemplate>

, , RibbonButtonDataTemplate datatemplate.

+3
1

, , , . .

0

Source: https://habr.com/ru/post/1780262/


All Articles