Since Silverlight 4 you can use Implicit Styles: http://weblogs.asp.net/lduveau/archive/2009/11/18/silverlight-4-implicit-styling.aspx
Basically it is just a style defined in resource without a key. As you don’t have a key you may wonder how you could inherit (BasedOn) from an implicit style?
Surprisingly lots of people are not aware of this, so here is how you can inherit from an implicit style:
1. Add a key to your implicit style (so it won’t be implicit anymore… but wait)
Microsoft use this technique in the Silverlight Toolkit, and their naming convention is DefaultXXXStyle.
So for a Button you would create DefaultButtonStyle like this sample:
<Style TargetType="Button" x:Key="DefaultButtonStyle">
<Setter Property="Background" Value="BlueViolet"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
2. Create a new Implicit Style based on this style:
<Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}" />
Now all your button will take DefaultButtonStyle as their implicit style.
Read more: Laurent Duveau
Basically it is just a style defined in resource without a key. As you don’t have a key you may wonder how you could inherit (BasedOn) from an implicit style?
Surprisingly lots of people are not aware of this, so here is how you can inherit from an implicit style:
1. Add a key to your implicit style (so it won’t be implicit anymore… but wait)
Microsoft use this technique in the Silverlight Toolkit, and their naming convention is DefaultXXXStyle.
So for a Button you would create DefaultButtonStyle like this sample:
<Style TargetType="Button" x:Key="DefaultButtonStyle">
<Setter Property="Background" Value="BlueViolet"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
2. Create a new Implicit Style based on this style:
<Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}" />
Now all your button will take DefaultButtonStyle as their implicit style.
Read more: Laurent Duveau