I am trying to create a Side menu in wpf as shown in the image...
The menu is binded to an ObservableCollection (MenuList) of the class
public class MenuItemModel
{
public int MenuID { get; set; }
public string MenuName { get; set; }
public ObservableCollection<MenuItemModel> SubMenuList { get; set; }
}
The Xaml I have been using for two level,
<ItemsControl ItemsSource="{Binding MenuList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<RadioButton x:Name="Menu"
Tag="{Binding MenuID}"
GroupName="MainMenu"
Style="{StaticResource MenuButtonStyle}"
Content="{Binding MenuName}"
Height="30"/>
<ListBox x:Name="SubMenu" ItemsSource="{Binding SubMenuList}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
It works perfectly for two levels. But I am unable to figure out how to implement third level menus (like version1, version2 in the image)? Is there any way to do this in the xaml without changing Data Models?