diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/GradientBackgroundShouldWorkWithImageButton.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/GradientBackgroundShouldWorkWithImageButton.png new file mode 100644 index 000000000000..282371d30499 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/GradientBackgroundShouldWorkWithImageButton.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml new file mode 100644 index 000000000000..a7b7dc8132e6 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml.cs new file mode 100644 index 000000000000..5776884b6cca --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml.cs @@ -0,0 +1,12 @@ +namespace Maui.Controls.Sample.Issues +{ + + [Issue(IssueTracker.Github, 23119, "Assigning a Brush of type RadialGradientBrush to the Background property of an ImageButton causes the BG to show a solid color", PlatformAffected.Android)] + public partial class Issue23119 : ContentPage + { + public Issue23119() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/GradientBackgroundShouldWorkWithImageButton.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/GradientBackgroundShouldWorkWithImageButton.png new file mode 100644 index 000000000000..1a14b42627aa Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/GradientBackgroundShouldWorkWithImageButton.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23119.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23119.cs new file mode 100644 index 000000000000..8067d0c5d65a --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23119.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue23119 : _IssuesUITest + { + public Issue23119(TestDevice testDevice) : base(testDevice) + { + } + + public override string Issue => "Assigning a Brush of type RadialGradientBrush to the Background property of an ImageButton causes the BG to show a solid color"; + + [Test] + [Category(UITestCategories.ImageButton)] + public void GradientBackgroundShouldWorkWithImageButton() + { + App.WaitForElement("imageButton"); + VerifyScreenshot(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/GradientBackgroundShouldWorkWithImageButton.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/GradientBackgroundShouldWorkWithImageButton.png new file mode 100644 index 000000000000..157845017fc0 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/GradientBackgroundShouldWorkWithImageButton.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/GradientBackgroundShouldWorkWithImageButton.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/GradientBackgroundShouldWorkWithImageButton.png new file mode 100644 index 000000000000..8b73febe7833 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/GradientBackgroundShouldWorkWithImageButton.png differ diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs index 2132103c7db5..ae3725cce833 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs @@ -24,6 +24,7 @@ protected override void DisconnectHandler(ShapeableImageView platformView) platformView.Click -= OnClick; platformView.Touch -= OnTouch; platformView.ViewAttachedToWindow -= OnPlatformViewAttachedToWindow; + platformView.LayoutChange -= OnPlatformViewLayoutChange; base.DisconnectHandler(platformView); @@ -37,6 +38,7 @@ protected override void ConnectHandler(ShapeableImageView platformView) platformView.Touch += OnTouch; platformView.ViewAttachedToWindow += OnPlatformViewAttachedToWindow; + platformView.LayoutChange += OnPlatformViewLayoutChange; base.ConnectHandler(platformView); } @@ -73,6 +75,12 @@ void OnFocusChange(object? sender, View.FocusChangeEventArgs e) VirtualView.IsFocused = e.HasFocus; } + void OnPlatformViewLayoutChange(object? sender, View.LayoutChangeEventArgs e) + { + if (sender is ShapeableImageView platformView && VirtualView is not null) + platformView.UpdateBackground(VirtualView); + } + void OnTouch(object? sender, View.TouchEventArgs e) { var motionEvent = e.Event;