Add color to WPF grid from code behind

D

DNB

I would like to add this color #E7EBF7 to my WPF data grid

I know that I can add light blue color using following:

Grid b = new Grid();

b.Background = System.Windows.Media.Brushes.LightBlue;



but how to add specific color (i.e. #E7EBF7 )



Thanks

DNB
 
N

Nicholas Paldino [.NET/C# MVP]

DNB,

Just use a SolidColorBrush, like so:

// Create the color first.
System.Windows.Media.Color color = System.Windows.Media.Color.FromRgb((byte)
0xE7, (byte) 0xEB, (byte) 0xF7);

// Create the brush.
System.Windows.Media.SolidColorBrush brush = new
System.Windows.Media.SolidColorBrush(color);

// Set the background.
b.Background = brush;
 
D

DNB

Thanks

DNB
Nicholas Paldino said:
DNB,

Just use a SolidColorBrush, like so:

// Create the color first.
System.Windows.Media.Color color =
System.Windows.Media.Color.FromRgb((byte) 0xE7, (byte) 0xEB, (byte) 0xF7);

// Create the brush.
System.Windows.Media.SolidColorBrush brush = new
System.Windows.Media.SolidColorBrush(color);

// Set the background.
b.Background = brush;


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DNB said:
I would like to add this color #E7EBF7 to my WPF data grid

I know that I can add light blue color using following:

Grid b = new Grid();

b.Background = System.Windows.Media.Brushes.LightBlue;



but how to add specific color (i.e. #E7EBF7 )



Thanks

DNB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top