Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting background of panel with custom color code

Tags:

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?

like image 465
Shyju Avatar asked Jul 14 '10 13:07

Shyju


People also ask

How do you change the background color on a panel?

You can quickly toggle among different background colors in the view panel by pressing Alt+B. You can also set the preferences to change the default background. Select Windows > Settings/Preferences > Color Settings.

What is code for background color?

background-color: rgba(255, 255, 255, 0);

How do you change the background color in Java?

In general, to set the JFrame background color, just call the JFrame setBackground method, like this: jframe. setBackground(Color. RED);

How do you code black background?

HTML color code for #000000.


1 Answers

BrushConverter bc = new BrushConverter();  
stackPanelFlasher.Background=  (Brush)bc.ConvertFrom("#C7DFFC"); 

Should do the job. If you want to make it waterproof, better would be

BrushConverter bc = new BrushConverter();  
Brush brush=(Brush)bc.ConvertFrom("#C7DFFC"); 
brush.Freeze();
stackPanelFlasher.Background=brush;

needs fewer resources...

like image 83
HCL Avatar answered Sep 22 '22 09:09

HCL