From 41576d3eede5dfc0e0fb9833287b4daa41a05581 Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman <93904422+Tamilarasan-Paranthaman@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:05:24 +0530 Subject: [PATCH 1/2] Fixed flyout content width issue --- .../Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs | 3 --- src/Core/src/Platform/Windows/MauiNavigationView.cs | 4 ++++ .../src/Platform/Windows/NavigationViewExtensions.cs | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs b/src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs index 58874bedcd52..b61e4525b862 100644 --- a/src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs +++ b/src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs @@ -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); diff --git a/src/Core/src/Platform/Windows/MauiNavigationView.cs b/src/Core/src/Platform/Windows/MauiNavigationView.cs index 6dd485acf974..5e417ae66d16 100644 --- a/src/Core/src/Platform/Windows/MauiNavigationView.cs +++ b/src/Core/src/Platform/Windows/MauiNavigationView.cs @@ -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 WinUI SDK 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; } diff --git a/src/Core/src/Platform/Windows/NavigationViewExtensions.cs b/src/Core/src/Platform/Windows/NavigationViewExtensions.cs index 1c9831e9fb1d..a36c2f0167f5 100644 --- a/src/Core/src/Platform/Windows/NavigationViewExtensions.cs +++ b/src/Core/src/Platform/Windows/NavigationViewExtensions.cs @@ -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; } From b9786998bbd3812212ce1cdc54243a14a9daece2 Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman <93904422+Tamilarasan-Paranthaman@users.noreply.github.com> Date: Tue, 15 Apr 2025 15:28:25 +0530 Subject: [PATCH 2/2] Updated details --- src/Core/src/Platform/Windows/MauiNavigationView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/Windows/MauiNavigationView.cs b/src/Core/src/Platform/Windows/MauiNavigationView.cs index 5e417ae66d16..73d9ee63a9cf 100644 --- a/src/Core/src/Platform/Windows/MauiNavigationView.cs +++ b/src/Core/src/Platform/Windows/MauiNavigationView.cs @@ -125,7 +125,7 @@ protected override void OnApplyTemplate() PaneContentGrid.Margin = new WThickness(0, 0, 0, 0); UpdateMenuItemsContainerHeight(); - // On WinUI SDK 1.7, it seems that if the PaneContentGrid width is not explicitly set, + // 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; }