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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns:controls="clr-namespace:Maui.Controls.Sample.Issues"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue23119">
<VerticalStackLayout>
<ImageButton
AutomationId="imageButton"
WidthRequest="100"
HeightRequest="100"
HorizontalOptions="Center">
<ImageButton.Background>
<RadialGradientBrush
Center="0.5,0.5"
Radius="0.5">
<GradientStop Color="green"
Offset="0.0"/>
<GradientStop Color="red"
Offset="1.0"/>
</RadialGradientBrush>
</ImageButton.Background>
</ImageButton>

<ImageButton
WidthRequest="100"
HeightRequest="100"
HorizontalOptions="Center">
<ImageButton.Background>
<LinearGradientBrush>
<GradientStop Color="green"
Offset="0.0"/>
<GradientStop Color="red"
Offset="1.0"/>
</LinearGradientBrush>
</ImageButton.Background>
</ImageButton>

<Button
WidthRequest="100"
HeightRequest="100"
HorizontalOptions="Center">
<Button.Background>
<RadialGradientBrush
Center="0.5,0.5"
Radius="0.5">
<GradientStop Color="green"
Offset="0.0"/>
<GradientStop Color="red"
Offset="1.0"/>
</RadialGradientBrush>
</Button.Background>
</Button>

<Button
WidthRequest="100"
HeightRequest="100"
HorizontalOptions="Center">
<Button.Background>
<LinearGradientBrush>
<GradientStop Color="green"
Offset="0.0"/>
<GradientStop Color="red"
Offset="1.0"/>
</LinearGradientBrush>
</Button.Background>
</Button>
</VerticalStackLayout>
</ContentPage>
12 changes: 12 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue23119.xaml.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
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.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -37,6 +38,7 @@ protected override void ConnectHandler(ShapeableImageView platformView)
platformView.Touch += OnTouch;
platformView.ViewAttachedToWindow += OnPlatformViewAttachedToWindow;

platformView.LayoutChange += OnPlatformViewLayoutChange;
base.ConnectHandler(platformView);
}

Expand Down Expand Up @@ -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;
Expand Down
Loading