william
william

Reputation: 11

How do you change the background colour of a button?

I am new to WPF and having trouble with something rather simple. I have set the background colour of my button like this:

<Button Background="FF0000"/>

I keep getting this error:

Invalid value for property 'Background': 'FF0000'

Also, if anyone knew the hex code of the background colour in the image below, or how to find it, that would be much appreciated.

Image

Upvotes: 0

Views: 134

Answers (1)

thatguy
thatguy

Reputation: 22089

You have to add a pound sign in front of the hex color code. For more information, you can refer to the documentation for SoliColorBrush and XAML attribute usage.

<Button Background="#FF0000"/>

The background color can be found by using an image editor, it is #393943.

<Button Background="#393943"/>

See this related Super User question for a variety of ways to pick a color from an image.

Upvotes: 1

Related Questions