Shalvin Interests

Wednesday, July 13, 2011

Silverlight Styles

Styles is a collection of property value you can apply to an element. In a way it is equivalent to the functionality of CSS in HTML. You store style object as a resource.

<UserControl.Resources>
    <Style x:Key="SimpleStyle" TargetType="Button">
        <Setter Property="Foreground" Value="Blue" />
        <Setter Property="Background" Value="Cyan"/>
    </Style>
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="White">
    <Button Style="{StaticResource SimpleStyle}" Content="Button" Height="23" HorizontalAlignment="Left" Margin="50,76,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="50,137,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
</Grid>

No comments:

Post a Comment