.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Resourcedictionary in Silverlight Using Blend

Posted By:Diptimaya Patra       Posted Date: April 05, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

Resourcedictionary in Silverlight Using Blend. In this article we will see how we can manage Styles in different files. Resource Dictionary is a cool feature available in Blend 3, where we can store our defined styles.
 

Introduction

In this article we will see how we can manage Styles in different files. Resource Dictionary is a cool feature available in Blend 3, where we can store our defined styles.

Crating Silverlight Project

Fire up Blend 3 and create a Silverlight Application. Name it as ResourceDictionaryInSL3.

image1.gif

We will do the simple thing, customizing a Button Control.

Add a Button to the Application. Right Click on it and choose Edit Template and then choose Edit a copy.

image2.gif

When you choose Edit a Copy a new dialog box pops up saying Create Style Resource.

First of all Name the Style for Example "MyButtonStyle".

Then you have Define option under that we have three choices to make to store the Style information.

image3.gif

The default is under This Document which will store under the Page's xaml code behind.

The Application option will store the Style information in App.xaml file.

The third option is grayed, as there is no Resource Dictionary. We will use the Resource Dictionary option.

Create a new Resource Dictionary by clicking New.

image4.gif

It asks for giving a name to the file. You can see the extension is xaml.

Now the Resource Dictionary option will be activated with proper file name.

image5.gif

Press ok to continue with our work.

You can see a new file named ResourceDictionary2.xaml added to the Project. As it has only Style information so there is no code behind for it.

image6.gif

I have done simple change to the Button. (I have changed the Background Gradient to Red)

image7.gif

image8.gif

Now we have finished editing the Template, exit editing template.

Open App.xaml in xaml code behind you will find the Resource Dictionary is added to the Application Resource.


  
    
    
    
      
    
    
  

If you see the Button Control in xaml code behind, you will find the Style is Bound to the Name you have given for the Style.

That's it you have successfully used Resource Dictionary In Silverlight 3 using Blend 3.

Enjoy Coding.

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend