Customizing Data Templates in WPF Menu (MenuAdv)

6 May 20211 minute to read

Data templates can be customized for items of the MenuAdv control. The next section explains how to customize the MenuItemAdv using data templates.

Item Template

You can customize how a business object is displayed as MenuItemAdv using ItemTemplate of MenuAdv. The MenuAdv displays hierarchical data. HierarchicalDataTemplate is used to define the ItemTemplate. The following code example shows the usage of ItemTemplate.

  • XAML
  • <syncfusion:MenuAdv ItemsSource="{Binding MenuItems}" >
    
    
    
    <syncfusion:MenuAdv.ItemTemplate>
    
    
    
    <HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
    
    <StackPanel Orientation="Horizontal">
    
    <Image Source="App.ico"  Width="15" Height="15"/>
    
    <TextBlock Text="{Binding Header}" FontWeight="Bold" 			FontStyle="Italic" />
    
    </StackPanel>
    
    </HierarchicalDataTemplate>
    
    
    
    </syncfusion:MenuAdv.ItemTemplate>
    
    
    
    </syncfusion:MenuAdv>

    NOTE

    View sample in GitHub

    Implementing the above code will generate the following MenuAdv control.

    Image showing the menu with ItemTemplate