Contact

Follow us on FB

Search

Another of the minor but potentially useful new features coming in Silverlight 5 – and already present in the Silverlight 5 beta – is style data binding. Simple put, style data binding allows you to use data-binding expressions to assign values to style setters. It may not sound that exciting, but among other things, it makes it easier than ever to include dynamic theming support in your Silverlight apps. There’s not a lot of documentation around this feature just yet, but as usual, a good example is better than documentation anyway. I built the app shown below to demonstrate

dynamic theming using style data binding. Here’s how it looks when it first appears on the screen: Clicking anywhere in the browser window instantly changes the theme colors: To make this work, and to leverage style data binding, I began by writing a simple class named ColorTheme that exposes brushes and colors through properties with names like AccentColor, AccentBrush, and TextBrush. (I also implemented INotifyPropertyChanged in the class since I intended to use it as a data source.) Then, in App.xaml, I declared an instance of ColorTheme, and I defined a few...(Read whole news on source site)