Wednesday 2 November 2011

Silverlight Styles

Styles in Silverlight is a collection of property values that we can apply to any element in one easy step.

Lets Define Style first :)

For example, we want to give some style like font and foreground color to Button.


//App.xaml
<Application.Resources>    
        <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="FontFamily" Value="Georgia" />
            <Setter Property="FontSize" Value="32" />
            <Setter Property="Foreground" Value="SlateGray" />
            <Setter Property="Padding" Value="20" />
            <Setter Property="Margin" Value="10" />
        </Style>
</Application.Resources>

Apply Style to Button :-

//MainPage.xaml
<Button VerticalAlignment="Top" Content="My Button Style" Style="{StaticResource ButtonStyle}" Height="81" />



No comments:

Post a Comment