Open Coloris opened 1 year ago
Also, when I add PresentationTraceSources.TraceLevel=High to the MenuItemsSource property binding, I get the following :
BindingExpression (hash=30400195): GetValue at level 0 from NavigationViewControlViewModel (hash=39567352) using RuntimePropertyInfo(NavigationItems): ObservableCollection`1 (hash=17472816 Count=2)
Created BindingExpression (hash=30400195) for Binding (hash=35943562) BindingExpression:Path=NavigationItems; DataItem=null;
Path: 'NavigationItems'
BindingExpression (hash=30400195): Default mode resolved to OneWay
BindingExpression (hash=30400195): Default update trigger resolved to PropertyChanged
BindingExpression (hash=30400195): Attach to Wpf.Ui.Controls.Navigation.NavigationView.MenuItemsSource (hash=64479624)
BindingExpression (hash=30400195): Resolving source
BindingExpression (hash=30400195): Found data context element: NavigationView (hash=64479624) (OK)
BindingExpression (hash=30400195): DataContext is null
BindingExpression (hash=30400195): Resolve source deferred
BindingExpression (hash=30400195): Resolving source
BindingExpression (hash=30400195): Found data context element: NavigationView (hash=64479624) (OK)
BindingExpression (hash=30400195): DataContext is null
BindingExpression (hash=30400195): Resolving source
BindingExpression (hash=30400195): Found data context element: NavigationView (hash=64479624) (OK)
BindingExpression (hash=30400195): Activate with root item NavigationViewControlViewModel (hash=39567352)
BindingExpression (hash=30400195): At level 0 - for NavigationViewControlViewModel.NavigationItems found accessor RuntimePropertyInfo(NavigationItems)
BindingExpression (hash=30400195): Replace item at level 0 with NavigationViewControlViewModel (hash=39567352), using accessor RuntimePropertyInfo(NavigationItems)
BindingExpression (hash=30400195): TransferValue - got raw value ObservableCollection`1 (hash=17472816 Count=2)
BindingExpression (hash=30400195): TransferValue - using final value ObservableCollection`1 (hash=17472816 Count=2)
` this._MenuItems = new ObservableCollection
this.RootNavigation.MenuItems = _MenuItems;`
What is the difference between MenuItems and MenuItemsSource?I also encountered a problem with the navigation menu not being displayed
Has any solution been found?
Tried with the latest 3.0.0-preview.8 and the issue is still present.
i also have problems with NavigationViewItem inside NavigationViewItem in XAML and binding in code, but it works for me
<ui:NavigationView
Grid.Row="1"
IsBackButtonVisible="Collapsed"
IsPaneToggleVisible="True"
Margin="5,0"
OpenPaneLength="310"
PaneDisplayMode="Left"
x:Name="RootNavigation">
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem Content="Tables" TargetPageType="{x:Type pages:FlightPage}" />
<ui:NavigationViewItem Content="Seating" TargetPageType="{x:Type pages:SeatingPage}" />
</ui:NavigationView.MenuItems>
</ui:NavigationView>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
(RootNavigation.MenuItems[0] as NavigationViewItem)!.MenuItems = new object[]
{
new NavigationViewItem("Flight", typeof(FlightPage)),
new NavigationViewItem("Person", typeof(PersonPage)),
new NavigationViewItem("Booking", typeof(BookingPage))
};
}
}
doesn't look good
Describe the bug
When a NavigationView control is set inside a UserControl View, the MenuItemsSource doesn't reflect the binding on the UI
Other properties are correctly set from the same ViewModel (TitleBar Title and IsPaneToggleVisible from the NavigationView control)
The MenuItemsSource property binding functions properly when used directly in the MainWindow as a View.
To Reproduce
See https://github.com/Coloris/wpfsandbox/tree/main
Expected behavior
The Binding should work and the UI display the MenuItems
Screenshots
No response
OS version
Windows 11 22h2 - Version 22621.1848 Visual Studio 2022 - Version 17.6.4
.NET version
7.0
WPF-UI NuGet version
3.0.0-preview.3
Additional context
No response