-
-
Notifications
You must be signed in to change notification settings - Fork 75
[Fix] NavigationView: Improve load & Fix ListView Size Initialization Issue #330
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a popup root exception that occurs when NavigationView is placed within a popup and makes changes to the IsPaneOpen property's default value. The main fix defers SplitView DisplayMode updates that occur during OnApplyTemplate to the OnLoaded event to prevent exceptions when NavigationView is in the popup root.
- Wraps the OnApplyTemplate logic in a try-finally block with a flag to track when the template is being applied
- Defers SplitView DisplayMode updates during OnApplyTemplate to the OnLoaded event to avoid popup root exceptions
- Removes the default value (true) from the IsPaneOpen dependency property, making it default to false
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| NavigationView.cs | Adds try-finally block around OnApplyTemplate, introduces flags to track template application state and defer SplitView DisplayMode updates to OnLoaded event |
| NavigationView.properties.cs | Removes explicit default value (true) from IsPaneOpenProperty metadata |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
source/iNKORE.UI.WPF.Modern.Controls/Controls/Windows/NavigationView/NavigationView.cs
Outdated
Show resolved
Hide resolved
|
|
||
| // Updating the splitview 'DisplayMode' property in some diplaymodes causes children to be added to the popup root. | ||
| // This causes an exception if the NavigationView is in the popup root itself (as SplitView is trying to add children to the tree while it is being measured). | ||
| // Due to this, we want to defer updating this property for all calls coming from `OnApplyTemplate`to the OnLoaded function. |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space between backtick and 'to' - should be 'OnApplyTemplate to'.
| // Due to this, we want to defer updating this property for all calls coming from `OnApplyTemplate`to the OnLoaded function. | |
| // Due to this, we want to defer updating this property for all calls coming from `OnApplyTemplate` to the OnLoaded function. |
| typeof(bool), | ||
| typeof(NavigationView), | ||
| new PropertyMetadata(true, OnIsPaneOpenPropertyChanged)); | ||
| new PropertyMetadata(OnIsPaneOpenPropertyChanged)); |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the default value (true) from IsPaneOpenProperty changes the default behavior from pane open to pane closed. This is a breaking change that affects any existing code relying on the pane being open by default. Consider adding the default value back with 'new PropertyMetadata(true, OnIsPaneOpenPropertyChanged)' or document this as a breaking change.
| new PropertyMetadata(OnIsPaneOpenPropertyChanged)); | |
| new PropertyMetadata(true, OnIsPaneOpenPropertyChanged)); |
…onView/NavigationView.cs Co-authored-by: Copilot <[email protected]>
Improve NavigationView load
Port from
microsoft-ui-xaml. Update visual state onOnLoadedevent to improve display effect.Fix ListView Size Initialization Issue
Set
NavigationView.IsPaneOpendefault to false to fix ListView size initialization issue ifNavigationViewdefaultDisplayModeisCompact.Test
Original:
After: