Skip to content

Fix/submenu navigation#1013

Merged
pomianowski merged 5 commits intolepoco:developmentfrom
koal44:fix/submenu-navigation
Mar 23, 2024
Merged

Fix/submenu navigation#1013
pomianowski merged 5 commits intolepoco:developmentfrom
koal44:fix/submenu-navigation

Conversation

@koal44
Copy link
Copy Markdown
Contributor

@koal44 koal44 commented Mar 23, 2024

Rework MenuItems and FooterMenuItems in NavigationView and NavigationViewItem. Once fixed, we can showcase submenu items in the Gallery App.

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

Submenu styling was already implemented in the NavigationView's Top mode but was omitted from the Gallery App, presumably due to bugs (see #759). The main problem, as I saw it, was the cohesion between Items, ItemsSource and their dependency properties (DPs).
Traditionally in a wpf ItemsControl, Items is a readonly property of type ItemsCollection which can maintain it's own ItemsSource. In WinUi, it's still readonly but of the more generic type IList<object> and it comes with a DP.

What is the new behavior?

The relationship between Items and ItemsSource has been redefined. For each Items/ItemsSource pair, there is now one collection (ObservableCollection<object>) created in the control's constructor. Lazy loading in the getter proved problematic because XAML bypasses the getter in favor of its own store when a DP is defined. Instead of replacing the collection, ItemsSource now clears and updates the collection's elements. The Items properties is now read-only and backed by a read-only dependency property, aligning with conventional WPF/WinUI practices.

Added submenu content to the Gallery App
Screenshot 2024-03-22 203837

koal44 added 4 commits March 22, 2024 16:49
…and avoid lazy loading for the collections due to XAML parsing issues

Lazy loading of the collections won't work because, with the introduction of the dependency properties, XAML parsing bypasses the CLR property wrappers, leading to null collections and errors.
@koal44 koal44 requested a review from pomianowski as a code owner March 23, 2024 04:59
@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. styles Topic is related to styles PR Pull request navigation Changes to navigation related controls. gallery WPF UI Gallery dotnet labels Mar 23, 2024
@pomianowski pomianowski self-assigned this Mar 23, 2024
@pomianowski pomianowski merged commit 5e663c5 into lepoco:development Mar 23, 2024
@koal44 koal44 deleted the fix/submenu-navigation branch March 23, 2024 19:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

controls Changes to the appearance or logic of custom controls. dotnet gallery WPF UI Gallery navigation Changes to navigation related controls. PR Pull request styles Topic is related to styles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants