You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Programmatically adding new NavigationViewItems to an existing NavigationView.MenuItems collection results in the added items rendering inside a generated NavigationViewItem node #1
privatevoidRenderMenu(){NavMain.MenuItems.Add(newNavigationViewItemSeparator());foreach(TarotSuitsuitindeck.Suits){// make a nav menu item for the suitNavigationViewItemnewMenu=newNavigationViewItem();newMenu.Content=suit.Suit;newMenu.Icon=newSymbolIcon(Symbol.OutlineStar);NavMain.MenuItems.Add("menu");}}
The resulting UI and live tree:
It looks like NavigationView.MenuItems.Add(object) is setting the value passed as the Content property of a generated NavigationViewItem, resulting in an added NavigationViewItem set as the Content property of a container NavigationViewItem.
Rendering really goes sideways on this:
If I pass a string to NavigationView.MenuItems.Add(object), the result is a single NavigationViewItem with the Content property set to the string. Not only that, but if I return all the items after they've been created, the returned list doesn't contain these extra, auto-generated NavigationViewItem controls, so I think this is happening when the control is rendered, rather than how the XAML controls are created before rendering.
I think this issue may be related to my windows build. This happened on 18231, but since updating to 18240, NavigationViewItem controls are being generated properly.
I'll leave this open though, since there might still be something else going on.
@ClairelyClaire that you for reporting this issue.
This behavior happens when a Windows.UI.Xaml.Controls.NavigationViewItem is added to a Microsoft.UI.Xaml.Controls.NavigationView. You only get the correct behavior when a Microsoft.UI.Xaml.Controls.NavigationViewItem is added to a Microsoft.UI.Xaml.Controls.NavigationView. The controls in the Microsoft.UI.Xaml namespace are from the NuGet package. The controls in the Windows.UI.Xaml namespace are the ones that are from the OS.
If you update your code to create Microsoft.UI.Xaml.Controls.NavigationViewItems, you should get the correct behavior.
Because the MenuItem property is typed to collection of object, the type system doesn't really help here.
Activity
GlitterHorn commentedon Sep 17, 2018
I think this issue may be related to my windows build. This happened on 18231, but since updating to 18240, NavigationViewItem controls are being generated properly.
I'll leave this open though, since there might still be something else going on.
kmahone commentedon Sep 17, 2018
@ClairelyClaire that you for reporting this issue.
This behavior happens when a Windows.UI.Xaml.Controls.NavigationViewItem is added to a Microsoft.UI.Xaml.Controls.NavigationView. You only get the correct behavior when a Microsoft.UI.Xaml.Controls.NavigationViewItem is added to a Microsoft.UI.Xaml.Controls.NavigationView. The controls in the Microsoft.UI.Xaml namespace are from the NuGet package. The controls in the Windows.UI.Xaml namespace are the ones that are from the OS.
If you update your code to create Microsoft.UI.Xaml.Controls.NavigationViewItems, you should get the correct behavior.
Because the MenuItem property is typed to collection of object, the type system doesn't really help here.
Thanks for the feedback.
GlitterHorn commentedon Sep 17, 2018
Thanks! I added this to my using:
I don't think I had that added when I posted this issue, but things look to be working now.
Step #1 for renaming Scroller enums.
Step #1: Introduce Scroller/ScrollViewer.ContentOrientation.
Replacing Scroller and ScrollViewer's IsChildAvailableWidthConstraine…
User/ranjeshj/itemsviewfi (#227)
Replacing Scroller and ScrollViewer's IsChildAvailableWidthConstraine…
Adding 1 to make it start with "Attempt #1" instead of "Attempt #0".
Test reporting improvements (#1039)
RadialGradientBrush initial commit (#1831)
ListViewItem/GridViewItem Visual Updates - Phase #1
Adding support for insider SDK usage, and ListViewItem/GridViewItem v…
Add and strengthen ItemsRepeater API tests (88 new, every public API …
[3/3] TableView: ListView paging and far-row focus, header naming/foc…
Compact WinUI Profiler snapshot tree display (#12421)