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
Apply Style to Button :-
For example, we want to give some style like font and foreground color to Button.
<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><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>
Apply Style to Button :-
//MainPage.xaml
<Button VerticalAlignment="Top" Content="My Button Style" Style="{StaticResource ButtonStyle}" Height="81" />
No comments:
Post a Comment