As you already know that, it is a new feature in Silverlight 5 and hence was not available in earlier version of Silverlight. So, how did we implement the style setter in previous versions? Let’s start from the scratch, where we will know how to use a Setter in Style and then we will jump to the Setter binding.
Earlier to Silverlight 5 Beta, we were actually coded value to the Setter property like this:
We also had the option to use a StaticResource directly to the Setter property value, where StaticResource has been defined in the Resources. Have a look into the below code:
So, what about Binding? Binding to the setter is a new feature in Silverlight 5. By using this feature, you can actually bind to a control property or a StaticResource like this:
More preferred example for this feature will be this:
Here, we have our ViewModel defined as a StaticResource in our XAML page. Now we can directly bind the Collection defined in the ViewModel and set it in the Style Setter instead of declaring it in the control level. Here “Path” defines the collection present in our ViewModel.
Hope, this post helped you to understand the feature and it’s uses. Stay tuned for my other posts on Silverlight 5 features.