Wednesday, February 8, 2012

WPF setting background in C# code

Several ways to do it:

A. Regular brush
your_control.Background = Brushes.Red;


B. New solid brush
your_control.Background = new SolidColorBrush(Colors.Red);


C. HEX color
var bc = new BrushConverter();
your_control.Background = (Brush)bc.ConvertFrom("#FFXX55XX");

No comments:

Post a Comment