Silverlight Feeds - All your Silverlight feeds in one place.

Sponsors

Wednesday, November 18, 2009

Silverlight 4 Beta: Implicit Styles

by andy@andybeaulieu.com via Andy's Blog on 11/18/2009 10:24:00 PM

The ability to create Implicit Styles has been a sorely missed feature in Silverlight… until Silverlight 4! The concept of an implicit style is very simple – you define how you want ALL instances of a control to look in one place (you can then override those styles if you need to).

Setting an implicit style in XAML

Let’s say we want all of our TextBox controls in our application to have White text on a Red background. We can step into our App.xaml and add the following XAML:

   
             
   


The key here is that we did NOT specify an x:Key value on the TextBox – only a TargetType. After this change, if we add a couple of TextBox controls to a UserControl, we’ll see the style take effect:


      
      


Of course, we can override a property that is styled if we wish – for example maybe we want to change the foreground colors of the TextBoxes to a color other than White:


      
      


Creating Implicit Styles in Blend

To create an Implicit Style in Blend, right-click an element and select Edit Template/Edit a Copy or Edit Template/Create Empty.

… then select the “Apply to all” radio button option in the Create Style Resource dialog:

Some Limitations

Currently, Silverlight 4 does not support BasedOn styling for Implicit Styles. This is possible in WPF and allows for the “tweaking” of a style at a local scope. For example, you may define an Implicit style for a TextBox at the application level, but then want to tweak just a couple of properties of the style in a local scope (maybe a UserControl or Container).

email it!bookmark it!digg it!

Original Post: Silverlight 4 Beta: Implicit Styles

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us