Skip to content
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
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue17789"
BackgroundImageSource="oasis.jpg">
<StackLayout>
<Label
AutomationId="WaitForStubControl"
Text="Issue 17789"
VerticalOptions="Center"
HorizontalOptions="Center" />
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 17789, "ContentPage BackgroundImageSource not working", PlatformAffected.iOS)]
public partial class Issue17789 : ContentPage
{
public Issue17789()
{
InitializeComponent();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue17789.cs
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.AppiumTests.Issues
{
public class Issue17789 : _IssuesUITest
{
public Issue17789(TestDevice device) : base(device)
{
}

public override string Issue => "ContentPage BackgroundImageSource not working";

[Test]
public void ContentPageBackgroundImageSourceWorks()
{
App.WaitForElement("WaitForStubControl");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions src/Core/src/Handlers/Page/PageHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ protected override ContentView CreatePlatformView()

public static void MapBackground(IPageHandler handler, IContentView page)
{
if (handler is IPlatformViewHandler invh && invh.ViewController is not null)
if (handler is IPlatformViewHandler platformViewHandler && platformViewHandler.ViewController is not null)
{
invh.ViewController.View?.UpdateBackground(page);
var provider = handler.GetRequiredService<IImageSourceServiceProvider>();
platformViewHandler.ViewController.View?.UpdateBackground(page, provider);
}
}

public static void MapTitle(IPageHandler handler, IContentView page)
{
if (handler is IPlatformViewHandler invh && invh.ViewController is not null)
if (handler is IPlatformViewHandler platformViewHandler && platformViewHandler.ViewController is not null)
{
if (page is ITitledElement titled)
{
invh.ViewController.Title = titled.Title;
}
platformViewHandler.ViewController.UpdateTitle(page);
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/Core/src/Platform/iOS/PageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UIKit;

namespace Microsoft.Maui.Platform
{
internal static class PageExtensions
{
public static void UpdateTitle(this UIViewController viewController, IContentView page)
{
if (page is not ITitledElement titled)
return;

viewController.Title = titled.Title;
}

public static void UpdateBackground(this UIView platformView, IContentView page, IImageSourceServiceProvider? provider)
{
if (page.Background is ImageSourcePaint image)
platformView.UpdateBackgroundImageSourceAsync(image.ImageSource, provider).FireAndForget();
else
platformView.UpdateBackground(page);
}
}
}