Skip to content

Commit 258a93b

Browse files
Updated Test sample
1 parent 09f5fff commit 258a93b

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

src/Controls/src/Core/Handlers/Shell/ShellHandler.Windows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public static void MapFlyoutBackground(ShellHandler handler, Shell view)
129129
view.FlyoutBackgroundColor?.AsPaint());
130130
}
131131

132+
//TODO: Make it public in .NET 10.
132133
internal static void MapFlyoutBackgroundImage(ShellHandler handler, Shell view)
133134
{
134135
var provider = handler.GetRequiredService<IImageSourceServiceProvider>();

src/Controls/tests/TestCases.HostApp/Issues/Issue21472.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Issue21472 : Shell
66
public Issue21472()
77
{
88
FlyoutBackgroundImage = "dotnet_bot.png";
9-
FlyoutBehavior = FlyoutBehavior.Locked;
9+
FlyoutBehavior = FlyoutBehavior.Flyout;
1010
FlyoutBackgroundImageAspect = Aspect.AspectFill;
1111
var flyoutItem1 = new FlyoutItem { Title = "Item1" };
1212
var tab1 = new Tab();
@@ -20,12 +20,19 @@ public class Issue21472ContentPage : ContentPage
2020
{
2121
public Issue21472ContentPage()
2222
{
23-
Content = new Label
23+
var button = new Button
2424
{
25-
Text = "Flyout Should Contain backgroundImage",
25+
Text = "RemoveFlyoutBackground",
2626
HorizontalOptions = LayoutOptions.Center,
2727
VerticalOptions = LayoutOptions.Center,
28-
AutomationId = "label"
28+
AutomationId = "button"
2929
};
30+
31+
button.Clicked += (sender, e) =>
32+
{
33+
Shell.Current.FlyoutBackgroundImage = null;
34+
};
35+
36+
Content = button;
3037
}
3138
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21472.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@ public Issue21472(TestDevice testDevice) : base(testDevice)
1010
}
1111
public override string Issue => "Shell FlyoutBackgroundImage doesn't shown";
1212

13-
[Test]
13+
[Test, Order(1)]
1414
[Category(UITestCategories.Shell)]
15-
public void ShellFlyoutBackgroundImageVerify()
15+
public void VerifyShellFlyoutBackgroundImage()
1616
{
17-
App.WaitForElement("label");
17+
App.WaitForElement("button");
18+
App.ShowFlyout();
19+
VerifyScreenshot();
20+
}
21+
22+
[Test, Order(2)]
23+
[Category(UITestCategories.Shell)]
24+
public void VerifyShellFlyoutBackgroundImageSetNull()
25+
{
26+
App.WaitForElement("button");
27+
App.Tap("button");
28+
App.ShowFlyout();
1829
VerifyScreenshot();
1930
}
2031
}

src/Core/src/Platform/Windows/NavigationViewExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ internal static async Task UpdateBackgroundImageSourceAsync(this MauiNavigationV
270270

271271
var service = provider.GetRequiredImageSourceService(imageSource);
272272
var nativeImageSource = await service.GetImageSourceAsync(imageSource);
273+
274+
if (nativeImageSource is null)
275+
{
276+
paneContentGrid.Background = null;
277+
return;
278+
}
273279

274280
var BackgroundImage = new ImageBrush
275281
{

0 commit comments

Comments
 (0)