I am trying to set a colour of an ellipse object in code behind. So far I'm doing it by using the SolidColorBrush method. Is there a way to insert the colour value in hexadecimal, like in CSS?
Here is a code that I am using:
ellipse.Fill = new SolidColorBrush(Colors.Yellow);
Something like this would work
ellipse.Fill =
new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF00DD"));
(Edit: It looks like this is WPF only. Alex Golesh has a blog post here about his Silverlight ColorConverter)
Although I prefer the Color.FromRgb
method
byte r = 255;
byte g = 0;
byte b = 221;
ellipse.Fill = new SolidColorBrush(Color.FromRgb(r,g,b));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With