The third part of the series is ready and it covers the following topics:
- Style is a dependency property. Because of this, it supports the following features:
- Data binding – it’s possible to bind a style to another (even though this is probably a very rare use case)
- Property change notifications – it is possible to get notified when the Style property changes, a little workaround is needed though
- ClearValue – when resetting the value of a Style, setting it to null may result in the element disappearing. It’s worth knowing what the difference between that and calling ClearValue are
- Declaring styles in code behind: creating styles programmatically is more complex that via XAML but at times this technique may be useful.
- Only dependency properties can be styled, styling CLR properties will result in either a compile time error or a runtime exception.
- Only classes descending from FrameworkElement have the Style property and thus can be styled.
You can read the detailed article on my Scott Logic blog – I hope you’ll find it useful.
The final part of the series will explore manipulating styles in runtime.