Silverlight 3 Quick Tip Styling Improvements

Silverlight 3 bring long-awaited improvements in styling mechanism: “BasedOn” mechanism, Merged Resource Dictionaries and eliminates “write once” style setting behavior. Let’s see those features.


Styles can be “derived” from one another. Perfect for cascading/inheriting styles.

Let’s define style for a… Button (well, in demos it is always a Button, TextBox, etc. ;))

<Style x:Key="BaseButtonStyle" TargetType="ButtonBase">
     <Setter Property="Width" Value="100"/>
     <Setter Property="Height" Value="25"/>
     <Setter Property="Margin" Value="5"/>

To “derive” from existing style we should specify BasedOn property

<Style x:Key="DerivedButtonStyle" TargetType="ButtonBase" 
  BasedOn="{StaticResource BaseButtonStyle}">
      <Setter Property="Background" Value="Red"/>
      <Setter Property="BorderBrush" Value="Blue"/>
      <Setter Property="BorderThickness" Value="3"/>

more here
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • MisterWong
  • Y!GG
  • Webnews
  • Digg
  • StumbleUpon
  • Reddit
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • XING

Leave a Reply

Your email address will not be published. Required fields are marked *