How to get a Brush from a RGB Code?

gurehbgui picture gurehbgui · Apr 26, 2013 · Viewed 53.9k times · Source

How can I get a Brush to set a Background of e.g. a Grid from a RGB Code.

I hace the RGB Code as a int:

R = 12
B = 0
G = 255

I need to know how to convert it into a Brush

Answer

Chris Sinclair picture Chris Sinclair · Apr 26, 2013
var brush = new SolidColorBrush(Color.FromArgb(255, (byte)R, (byte)G, (byte)B));
myGrid.Background = brush;