Click here to Skip to main content
13,704,995 members
Click here to Skip to main content
Add your own
alternative version


1 bookmarked
Posted 19 May 2011
Licenced CPOL

Binding on Style Setter in Silverlight 5

, 19 May 2011
Rate this:
Please Sign up or sign in to vote.
Binding on Style setter in Silverlight 5

Continuing our discussion on Silverlight 5 features. In earlier posts, we discussed about Text Advancement in Silverlight 5. In this post, we will discuss another new feature called Binding on Style Setter. This feature is very useful for the XAML designer. If you are an XAML designer, you must be aware of this cool new feature.

Read the complete post where we will discuss how we can bind to a Style Setter.

As you already know, 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 scratch, where we will know how to use a Setter in Style and then we will jump to the Setter binding.

Prior to Silverlight 5 Beta, we actually coded values to the Setter property like this:


We also had the option to use a StaticResource directly as the Setter property value, where StaticResource has been defined in the Resources. Have a look at the code below:


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 its uses. Stay tuned for my other posts on Silverlight 5 features.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kunal Chowdhury «IN»
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Book authored:

Connect with me on:

My CodeProject Awards/Prizes:

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Brij28-May-11 21:28
mvpBrij28-May-11 21:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 19 May 2011
Article Copyright 2011 by Kunal Chowdhury «IN»
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid