Button color change on click or hover

Viewed 56

I added a button component in my application, and I am expecting it to change the color when user hovers on it or click it.

But looks like that's not the default behavior of the button.

Is there a way to get that behavior maybe by setting some attribute?

1 Answers

You can simply use a event handler to set the color of the button when clicking it. Here's the code sample below for your reference:

<Button Clicked="Button_Clicked">

Code in backend:

private void Button_Clicked(object sender, EventArgs e)
{
   var button = (Button)sender;
   button.BackgroundColor = Color.FromArgb("#FFA07A");
}

Update:

I found a simialr issue for your scenerio in Github, you can follow it up here:https://github.com/dotnet/maui/issues/9552

Related