I am using WinUI 3 NavigationView in my newly created Windows App application which I am trying to work on the basics with Template Studio for WinUI. I am trying to make NavigationViewItem dynamic as shown in Microsoft Blog where I can manage it with user permissions from SQL Server data.
I am new to XAML and MVVM! I understand that I will get the data for NavigationView via ViewModel. I created a couple of demo projects and tried them. I have solved the values such as menu name, submenu, and icon information. However, I cannot Bind the x:Uid value. I did some research and could not find how to make a dynamic structure without using Bind in properties starting with x:.
Here are my sample codes:
<NavigationViewItem Content="{x:Bind Name}" MenuItemsSource="{x:Bind Children}" x:Uid="{Bind Id}" >
<NavigationViewItem.Icon>
<SymbolIcon Symbol="{x:Bind CategoryIcon}" />
</NavigationViewItem.Icon>
</NavigationViewItem>
new Category(){
Id = "21",
Name = "Menu item 7",
CategoryIcon = "Home",
Children = new ObservableCollection<Category>() {
new Category() { Id = "211", Name = "Menu item 8", CategoryIcon = "Home" },
new Category() { Id = "212", Name = "Menu item 9", CategoryIcon = "Home" }
}
}
and error message: