Setting background of panel with custom color code

Viewed 60003

In WPF,I can set the background of a stack panel using the below code

stackPanelFlasher.Background = Brushes.Aqua;

How can I set the color as a hex color code for example #C7DFFC?

4 Answers

The following oneliner should work.

something.Background = (Brush)new BrushConverter().ConvertFrom("#C7DFFC");
Related