question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Binding an Empty Collection to MenuItemSource of NavigationViewItem still shows a Chevron

See original GitHub issue

Describe 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:

  1. Use the model
public class Item
{
    public string Content { get; set; }
    public Collection<Item> Children { get; set; }
}
  1. 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:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

5reactions
MarkIvanDevcommented, Jun 25, 2020

I started making the changes in my local branch of the repo. Will try to submit a pull request later.

3reactions
MarkIvanDevcommented, Jul 1, 2020

Thank you @Felix-Dev and @chingucoding for helping me through my first pull request.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found