user7546299
user7546299

Reputation:

Button's Background in Xaml UWP

in a UWP application I have a button its Background property is set to "DeepPink", but whenever I hover my mouse over it, it changes to gray (the default color),

here is my code:

<Button Content="Hello World" Margin="100,0,0,0" Background="DeepPink"/>

Am I missing something??

Upvotes: 1

Views: 1009

Answers (2)

Divyesh
Divyesh

Reputation: 2391

The best alternative would be to create Buttons like UI using Frame and Label. In this case, the background color will remain the same.

Example:

<Frame Padding="8" WidthRequest="100" HasShadow="False" BorderColor="Gray" 
       HorizontalOptions="Center">
       <Label Text="Button" HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>

Upvotes: 0

Pedro Lamas
Pedro Lamas

Reputation: 7233

That only defines the default state of the button, not the hover state.

You can either create a custom control template (you can see an example here), or go the easy way of changing colors with Lightweight styling - I'd recommend the second!

Upvotes: 1

Related Questions