Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wpf/Silverlight: How to convert hex value into Color?

I know how to create a SolidColorBrush of color blue and return it like this within a converter:

return new SolidColorBrush(Colors.Blue);

However what if I needed the SolidColorBrush to be of this Hex value? #44FFFF00 ?

How do I do that?

Thanks,

like image 865
Houman Avatar asked Jun 13 '11 21:06

Houman


3 Answers

new SolidColorBrush(Color.FromArgb(0x44, 0xFF, 0xFF, 0));

(Documentation)

Note: Don't use Color.FromRgb() (without the A) if your code will be shared in both Silverlight and WPF, as the FromRgb method doesn't exist in Silverlight.

like image 190
Phil Avatar answered Nov 07 '22 18:11

Phil


Try

(Brush)(new BrushConverter().ConvertFrom("#44FFFF00"));

much better IMHO

like image 41
Danish Khan Avatar answered Nov 07 '22 16:11

Danish Khan


Try

new SolidColorBrush(Color.FromArgb(0x44FFFF00));
like image 2
Manius Avatar answered Nov 07 '22 17:11

Manius