How to fill a rectangle with a hexadecimal color value?

'#10eeee' 

Here is what I am trying to do:

 groupRectangle.Fill = Color.FromHex? 
+4
source share
1 answer

You are looking for ColorConverter.ConvertFromString .

 Color color = (Color)ColorConverter.ConvertFromString("#10eeee"); SolidColorBrush myBrush = new SolidColorBrush(color); 

You will need using System.Windows.Media; at the top of your program.

Next line Color formats should be supported .

Edit: You can also use BrushConverter .

+9
source

Source: https://habr.com/ru/post/1314694/


All Articles