Data for Silverlight
WPF and Silverlight Styling

In WPF, you can set styles implicitly. When you set styles implicitly all instances of a particular type can be styled at once. For example, the WPF C1DropDown control might be styled with the following markup:

Copy Code
<Grid>
    <Grid.Resources>
        <Style TargetType="{x:Type c1:C1DropDown}">
            <Setter Property="Background" Value="Red" />
        </Style>
    </Grid.Resources>
    <c1:C1DropDown 
        Height="30" 
        HorizontalAlignment="Center" 
        Name="C1DropDown1" 
        VerticalAlignment="Center" 
        Width="100" />
</Grid>

This would set the background color of the control to red as in the following image:

All C1DropDown controls in the grid would also appear red; C1DropDown controls outside of the Grid would not appear red. This is what is meant by implicit styles. The style is assigned to all controls of a particular type. Inherited controls would also inherit the style.

Silverlight, however, does not support implicit styles. In Silverlight you could add the style to the Grid’s resources similarly:

Copy Code
<Grid.Resources>
    <Style x:Key="DropDownStyle" TargetType="c1:C1DropDown">
        <Setter Property="Background" Value="Red" />
    </Style>
</Grid.Resources>

But the Silverlight C1DropDown control would not be styled unless the style was explicitly set, as in the following example:

<c1:C1DropDown Height="30" HorizontalAlignment="Center" Name="C1DropDown1" VerticalAlignment="Center" Width="100" Style="{StaticResource DropDownStyle}"/>

While this is easy enough to set on one control, if you have several controls it can be tedious to set the style on each one. That is where the ImplicitStyleManager comes in. See Using the ImplicitStyleManager for more information.

See Also