How to use hex colour for SolidColorBrush with Windows Phone

163 Views Asked by At

I'm trying to use a hex colour (#E32017) programmatically for text within a textblock but it's not working. Does anyone know how a hex colour can used instead of Colors.Red when it comes to textblocks for Windows Phone?

TextBlock textBlock = new TextBlock();
textBlock.Inlines.Add(new Run { Text = "H", Foreground = new SolidColorBrush(Colors.Red) });
1

There are 1 best solutions below

2
On BEST ANSWER

You can call the Color.FromArgb method and specify the individual red, green, and blue components of your color:

Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xE3, 0x20, 0x17))