Skip to content

Conversation

@Jack251970
Copy link
Contributor

Improve NavigationView load

Port from microsoft-ui-xaml. Update visual state on OnLoaded event to improve display effect.

Fix ListView Size Initialization Issue

Set NavigationView.IsPaneOpen default to false to fix ListView size initialization issue if NavigationView default DisplayMode is Compact.

Test

Original:

Screenshot 2025-08-08 205447

After:

Screenshot 2025-08-09 092933

@Jack251970 Jack251970 changed the title Improve NavigationView load & Fix ListView Size Initialization Issue NavigationView: Improve load & Fix ListView Size Initialization Issue Aug 28, 2025
@Jack251970 Jack251970 changed the title NavigationView: Improve load & Fix ListView Size Initialization Issue [Fix] NavigationView: Improve load & Fix ListView Size Initialization Issue Aug 29, 2025
@NotYoojun NotYoojun requested a review from Copilot October 31, 2025 16:19
Copy link

Copilot AI left a 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.


// 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.
Copy link

Copilot AI Oct 31, 2025

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'.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
typeof(bool),
typeof(NavigationView),
new PropertyMetadata(true, OnIsPaneOpenPropertyChanged));
new PropertyMetadata(OnIsPaneOpenPropertyChanged));
Copy link

Copilot AI Oct 31, 2025

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.

Suggested change
new PropertyMetadata(OnIsPaneOpenPropertyChanged));
new PropertyMetadata(true, OnIsPaneOpenPropertyChanged));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants