Skip to content

[Windows] Fixed the flyout content width not being set correctly after updating to WinUI SDK 1.7 #28996

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

Merged
merged 2 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ void ShellElementPropertyChanged(object sender, PropertyChangedEventArgs e)
if (ShellView == null)
return base.MeasureOverride(availableSize);

if (!ShellView.IsPaneOpen)
return base.MeasureOverride(availableSize);

if (ShellView.OpenPaneLength < availableSize.Width)
return base.MeasureOverride(availableSize);

Expand Down
4 changes: 4 additions & 0 deletions src/Core/src/Platform/Windows/MauiNavigationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ protected override void OnApplyTemplate()
// It causes the content to not be flush up against the title bar
PaneContentGrid.Margin = new WThickness(0, 0, 0, 0);
UpdateMenuItemsContainerHeight();

// On WinAppSDK 1.7, it seems that if the PaneContentGrid width is not explicitly set,
// it takes on the desired width of its child.
PaneContentGrid.Width = OpenPaneLength;
}


Expand Down
10 changes: 10 additions & 0 deletions src/Core/src/Platform/Windows/NavigationViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,19 @@ public static void UpdateFlyoutBehavior(this MauiNavigationView navigationView,
public static void UpdateFlyoutWidth(this MauiNavigationView navigationView, IFlyoutView flyoutView)
{
if (flyoutView.FlyoutWidth >= 0)
{
navigationView.OpenPaneLength = flyoutView.FlyoutWidth;
}
else
{
navigationView.OpenPaneLength = 320;
}

if (navigationView.PaneContentGrid is not null)
{
navigationView.PaneContentGrid.Width = navigationView.OpenPaneLength;
}

// At some point this Template Setting is going to show up with a bump to winui
//handler.PlatformView.OpenPaneLength = handler.PlatformView.TemplateSettings.OpenPaneWidth;
}
Expand Down