Skip to content
59 changes: 59 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue31372.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 31372, "IsPresented=true Not Working on Initial Value in FlyoutPage", PlatformAffected.UWP | PlatformAffected.macOS)]

public class Issue31372 : NavigationPage
{
public Issue31372()
{
PushAsync(new Issue31372Page());
}
}

public class Issue31372Page : FlyoutPage
{
public Issue31372Page()
{

// Create Flyout Page
var flyoutPage = new ContentPage
{
Title = "Flyout",
Content = new StackLayout
{
Children =
{
new Label
{
Text = "This is Flyout",
AutomationId = "FlyoutLabel"
}
}
}
};

// Create Detail Page
var detailPage = new ContentPage
{
Title = "Detailpage",
Content = new StackLayout
{
Padding = 16,
Spacing = 16,
Children =
{
new Label
{
Text = "This is Detail Page which displays additional information."
},
}
}
};

// Assign Flyout and Detail
Flyout = flyoutPage;
Detail = new NavigationPage(detailPage);
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
IsPresented = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue31372 : _IssuesUITest
{
public override string Issue => "IsPresented=true Not Working on Initial Value in FlyoutPage";

public Issue31372(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.FlyoutPage)]
public void VerifyIsPresentedInitialValue()
{
App.WaitForElement("FlyoutLabel");
}
}
}
10 changes: 10 additions & 0 deletions src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ protected override void ConnectHandler(RootNavigationView platformView)
_navigationRootManager = MauiContext?.GetNavigationRootManager();
platformView.PaneOpened += OnPaneOpened;
platformView.PaneClosed += OnPaneClosed;
platformView.Loaded += OnLoaded;
}

void OnLoaded(object sender, RoutedEventArgs e)
{
if (VirtualView is not null)
{
PlatformView.IsPaneOpen = VirtualView.IsPresented;
}
}
Comment on lines +27 to 33
Copy link
Preview

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OnLoaded event handler will fire every time the control is loaded, but the IsPresented synchronization only needs to happen once. Consider unsubscribing from the Loaded event after the first execution to avoid unnecessary repeated executions.

Copilot uses AI. Check for mistakes.


protected override void DisconnectHandler(RootNavigationView platformView)
{
platformView.PaneOpened -= OnPaneOpened;
platformView.PaneClosed -= OnPaneClosed;
platformView.Loaded -= OnLoaded;
}

void OnPaneOpened(NavigationView sender, object args)
Expand Down
10 changes: 8 additions & 2 deletions src/Core/src/Handlers/Window/WindowHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public partial class WindowHandler : ElementHandler<IWindow, UIWindow>
protected override void ConnectHandler(UIWindow platformView)
{
base.ConnectHandler(platformView);

#if MACCATALYST
CoreFoundation.DispatchQueue.MainQueue.DispatchAsync(() =>
{
_frameObserverProxy.Connect(VirtualView, platformView);
});
#else
_frameObserverProxy.Connect(VirtualView, platformView);

#endif

// For newer Mac Catalyst versions, we want to wait until we get effective window dimensions from the platform.
if (OperatingSystem.IsMacCatalystVersionAtLeast(16))
{
Expand Down
Loading