diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs
index 2775bc88904a..469754b94148 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs
+++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.cs
@@ -76,6 +76,11 @@ protected override void OnAppearing()
AppShell!.FlyoutHeaderBehavior = (FlyoutHeaderBehavior)flyoutHeaderBehavior.SelectedIndex;
}
+ void OnToggleFlyoutIsPresented(object sender, EventArgs e)
+ {
+ AppShell!.FlyoutIsPresented = !AppShell!.FlyoutIsPresented;
+ }
+
void OnToggleFlyoutBackgroundColor(object sender, EventArgs e)
{
AppShell!.RemoveBinding(Shell.FlyoutBackgroundProperty);
diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml
index 7fae4ca459cf..f1b1ee64a747 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml
+++ b/src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellChromeGallery.xaml
@@ -13,6 +13,10 @@
Text="Flyout Behavior"
Style="{StaticResource Headline}"/>
+
+
diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs
index f3d917de1b2f..62a627b2c233 100644
--- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs
+++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs
@@ -183,9 +183,10 @@ protected override bool DrawChild(Canvas canvas, AView child, long drawingTime)
canvas.DrawRect(0, 0, Width, Height, _scrimPaint);
}
- if (!FlyoutFirstDrawPassFinished && _flyoutContent != null)
+ if (!FlyoutFirstDrawPassFinished && _flyoutContent is not null)
{
- if (child == _flyoutContent?.AndroidView)
+ // If the AndroidView property which is the DrawerLayout is initialized at this point, the Flyout first draw pass finished.
+ if (_flyoutContent?.AndroidView is not null)
FlyoutFirstDrawPassFinished = true;
if (this.IsDrawerOpen(_flyoutContent.AndroidView) != _shellContext.Shell.FlyoutIsPresented)
diff --git a/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs
new file mode 100644
index 000000000000..7b7cee65cd5e
--- /dev/null
+++ b/src/Controls/tests/DeviceTests/Elements/Shell/ShellFlyoutTests.Android.cs
@@ -0,0 +1,35 @@
+using AndroidX.DrawerLayout.Widget;
+using Microsoft.Maui.Controls;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Microsoft.Maui.DeviceTests
+{
+ [Category(TestCategory.Shell)]
+ public partial class ShellTests
+ {
+ [Fact(DisplayName = "FlyoutIsPresented=true sets the visible status of the Shell Flyout.")]
+ public async Task FlyoutIsPresentedOpenDrawer()
+ {
+ await RunShellTest(shell =>
+ {
+ shell.FlyoutContent = new VerticalStackLayout() { new Label() { Text = "Flyout Content" } };
+ },
+ async (shell, handler) =>
+ {
+ // 1. Set FlyoutIsPresented=true to make the Shell Flyout visible.
+ shell.FlyoutIsPresented = true;
+
+ var dl = GetDrawerLayout(handler) as DrawerLayout;
+ Assert.NotNull(dl);
+
+ await AssertionExtensions.AssertEventually(() =>
+ {
+ // 2. Check that the Flyout has size.
+ var flyoutFrame = GetFlyoutFrame(handler);
+ return flyoutFrame.Width > 0 && flyoutFrame.Height > 0 && dl.IsOpen;
+ });
+ });
+ }
+ }
+}