Getting Started with ComponentOne Studio Silverlight Edition
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:

XAML
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 of the control to be the color 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:

XAML
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:

XAML
Copy Code
<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's where the ImplicitStyleManager comes in. See Using the ImplicitStyleManager for more information.

 

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback