Nothing is everything.

Saturday, January 2, 2010

Handle Resources programmatically

//Add resources.
window.Resources.Add("backgroundBrush", new SolidColorBrush(Colors.Blue));
window.Resources.Add("borderBrush", new SolidColorBrush(Colors.Red));

//Access resources.
Button button = new Button();
button.Background = (Brush)button.FindResource("backgroundBrush");
button.BorderBrush = (Brush)button.FindResource("borderBrush");


 



WPF unleashed, page 254.

No comments:

Post a Comment

Followers