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
4 changes: 3 additions & 1 deletion src/Controls/src/Core/HandlerImpl/Button/Button.Impl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
Expand All @@ -15,6 +15,8 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
Handler?.UpdateValue(nameof(IButtonStroke.StrokeColor));
else if (propertyName == BorderWidthProperty.PropertyName)
Handler?.UpdateValue(nameof(IButtonStroke.StrokeThickness));
else if (propertyName == ImageSourceProperty.PropertyName)
Handler?.UpdateValue(nameof(IImage.Source));
}

void IButton.Clicked()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Android.Text;
using AndroidX.AppCompat.Widget;
Expand Down Expand Up @@ -77,6 +77,31 @@ public async Task CharacterSpacingInitializesCorrectly()
Assert.Equal(expectedValue, values.PlatformViewValue, EmCoefficientPrecision);
}

[Theory]
[InlineData("red.png", "#FF0000")]
[InlineData("green.png", "#00FF00")]
public async Task ImageSourceUpdatesCorrectly(string filename, string colorHex)
{
var image = new ButtonStub
{
ImageSource = new FileImageSourceStub("black.png"),
};

// Update the Button Icon
image.ImageSource = new FileImageSourceStub(filename);

await InvokeOnMainThreadAsync(async () =>
{
var handler = CreateHandler(image);

bool imageLoaded = await Wait(() => ImageSourceLoaded(handler));

Assert.True(imageLoaded);
var expectedColor = Color.FromArgb(colorHex);
await handler.PlatformView.AssertContainsColor(expectedColor);
});
}

AppCompatButton GetNativeButton(ButtonHandler buttonHandler) =>
buttonHandler.PlatformView;

Expand Down