-
-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix submenu navigation in NavigationViewItem #759
Conversation
The feature for submenus in NavigationViewTop was previously implemented but left unused prolly because of odd behavior such as stack overflow errors in AutoSuggest. The problem was traced to the NavigationViewItem.MenuItems dependency property, where a new ObservableCollection was incorrectly used as the default value. According to [MS Docs], "dependency property metadata shouldn't include a default reference-type value because that value will be assigned to all instances of the class, creating a singleton class."
Why did you remove the
If one of those was broken, then it's better to fix it instead of removing one of the options. You should be able to define a menu directly in XAML or bind to an |
Ah, thx for the feedback. My intent wasn't to limit options but to keep MenuItems to a single source of truth. I agree that NavigationViewItem is fundamentally an ItemsControl, and retaining MenuItemsSource makes sense. To test compatibility with view models, I made an experimental branch here and basically ran smack into a bug where binding to MenuItems nullified the collection. I'll keep working on it in the morning. |
Here's an update on |
The feature for submenus in NavigationViewTop was previously implemented but left unused prolly because of odd behavior such as stack overflow errors in AutoSuggest. The problem was traced to the NavigationViewItem.MenuItems dependency property, where a new ObservableCollection was incorrectly used as the default value. According to [MS Docs], "dependency property metadata shouldn't include a default reference-type value because that value will be assigned to all instances of the class, creating a singleton class."
…oal44/wpfui into feature/add-submenu-navigation
The feature for submenus in NavigationViewTop was previously implemented but left unused prolly because of odd behavior such as stack overflow errors in AutoSuggest.
The problem was traced to the NavigationViewItem.MenuItems dependency property, where a new ObservableCollection was incorrectly used as the default value. According to MS Docs, "dependency property metadata shouldn't include a default reference-type value because that value will be assigned to all instances of the class, creating a singleton class."
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
In the Gallery app if you add submenu items to NavigationView.Top you will get stack overflow
errors on AddItemsToAutoSuggestBoxItems(IList list) for menuItems.
<ui:NavigationView PaneDisplayMode="Top">
ui:NavigationView.MenuItems
<ui:NavigationViewItem Content="Menu Item 1"
ui:NavigationViewItem.MenuItems
<ui:NavigationViewItem Content="Menu SubItem 1" />
<ui:NavigationViewItem Content="Menu SubItem 2" />
</ui:NavigationViewItem.MenuItems>
</ui:NavigationViewItem>
Issue Number: N/A
What is the new behavior?
Other information