Binding an Empty Collection to MenuItemSource of NavigationViewItem still shows a Chevron
See original GitHub issueDescribe the bug
Binding an Empty Collection to the MenuItemSource
property of NavigationViewItem
still shows a Chevron.
Steps to reproduce the bug
Steps to reproduce the behavior:
- Use the model
public class Item
{
public string Content { get; set; }
public Collection<Item> Children { get; set; }
}
- Using the object
var item = new Item { Content = "Sample", Children = new Collection<Item>() };
And bind as
<winui:NavigationViewItem
Content="{x:Bind Content}"
MenuItemsSource="{x:Bind Children, Mode=OneWay}">
</winui:NavigationViewItem>
Expected behavior
Currently, the check is only being made if the MenuItemsSource
is null.
https://github.com/microsoft/microsoft-ui-xaml/blob/f41ff56db7bc90c4cf6ce08a3c9dbd024911b03d/dev/NavigationView/NavigationViewItem.cpp#L483
It should treat an empty collection bound to MenuItemsSource
as no Children, thus not showing a Chevron.
Screenshots
Version Info
NuGet package version:
[Microsoft.UI.Xaml 2.4.2]
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
May 2020 Update (19041) | Yes |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Xbox | |
Surface Hub | |
IoT |
Additional context
I don’t know if this is by design. And if it is, what could be made to have a workaround this. Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
UWP: NavigationView.MenuItems results empty if ...
I created a new UWP project with a NavigationView (winui 2.4) in MainPage.xaml. I proceeded by binding a hierarchical ObservableCollection to ...
Read more >NavigationViewItem.MenuItemsSource Property
This example adds hierarchy by defining the item template to be a NavigationViewMenuItem, with its Content set to be the label of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I started making the changes in my local branch of the repo. Will try to submit a pull request later.
Thank you @Felix-Dev and @chingucoding for helping me through my first pull request.