Resource Dictionary

We always look for the option of Reusability. So, what is the way in Silverlight where we can make use of this concept ? When we are making any design and we as a designer ordeveloper dont wont to do the same work again which we have done before.

Here is the concept called Resource Dictionary , which helps in solving this problem –


With this we can manage Styles in different files. This is feature availed to us where we can store our defined or custom styles.


1) Create a new Silveright project either in Blend or through Visual studio. If creating through Visual Studio , open the MainPage.xaml in Blend, by right clicking the same and choosing – “Open with Expression Blend” from the drop down box.

I will use a simple Object – “Button”, as an example. You can use the same concept for any Element you like.

2) Add a Button to the LayoutRoot.

3) Right Click the Button and choose “Edit Template” and then “Edit a copy”

  Edit template

3) Now, after this a new Pop-up Box comes up “Create Style Resource”. Name the Style – I have named it as  “MyNewButtonStyle”.  Now, in “Define Option” , Three choices are given which means – Where to store the Style          

    Naming resource

The Default option is – “This Document” – which means whatever changes you make will be reflected in this document only. The “Application” Option will store the Style information in App.xaml file.  Third Option is “Resource Dictionary” which we are dealing about , but this option is grayed as there is no resource dictionary we have made as of now.

4) So, Now go to the File>New Item> Resource Dictionary. Name your Resource Dictionary. NOTE: Look at the extension , its Xaml.

5) This will  make your Third Option in Resource Dictionary active, reflecting the proper file name.

resource dictionary

Press “Ok”.

6) I have made some small changes in the button.


7) open App.xaml in xaml code view and you can see that – Resource dictionary has been added.


8) Now if you see the Button Xaml – you can see that Style is bound to the name you have given to the Style. Here for me it will show “MyNewButtonStyle”, which I have given in Step 3.


9) Now, if you open the Resource dictionary file which has .xaml extension , you can see what changes you have made. Like – I have made changes for the Button.  ( I am not mentioning it here as , its a big file ) you can see in the same in your PC.

This is how we have made use of Resource Dictionary.

10) So, Now that we have created the Resource Dictionary , and as we want to use the same dictionary in another project .  Its straight forward you, have to just refer the name of the resource dictionary under the three option “Create Style Resource”. And you are done.


15 responses to “Resource Dictionary

    • Thanks alot.. its just the experience I shared.. I am glad this proved to be of some help to you and people alike…

  1. Great post. I used to be checking continuously this blog and I’m inspired! Very useful information specially the final part 🙂 I take care of such information a lot. I used to be looking for this particular information for a long time. Thanks and best of luck.

    • Please go ahead!! This blog or articles is to just share information I came across..
      I would be glad if it come to use for other user base…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s