<UserControl.Resources>
<Style x:Key="ColouredContentControlStyle" TargetType="ContentControl">
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="100" />
<Setter Property="Margin" Value="10" />
<Setter Property="FontFamily" Value="Verdana" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontStyle" Value="Italic" />
</Style>
<Style x:Key="ColouredCheckBoxStyle" BasedOn="{StaticResource ColouredContentControlStyle}" TargetType="CheckBox">
<Setter Property="Width" Value="154" />
</Style>
<Style x:Key="RedButtonStyle" BasedOn="{StaticResource ColouredContentControlStyle}" TargetType="Button">
<Setter Property="Foreground" Value="Red" />
</Style>
<Style x:Key="GreenButtonStyle" BasedOn="{StaticResource ColouredContentControlStyle}" TargetType="Button">
<Setter Property="Foreground" Value="Green" />
</Style>
<Style x:Key="YellowCheckBoxStyle" BasedOn="{StaticResource ColouredCheckBoxStyle}" TargetType="CheckBox">
<Setter Property="Foreground" Value="Yellow" />
</Style>
<Style x:Key="OrangeRadioButtonStyle" BasedOn="{StaticResource ColouredContentControlStyle}" TargetType="RadioButton">
<Setter Property="Foreground" Value="Orange" />
<Setter Property="Width" Value="190" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<StackPanel Orientation="Vertical" Margin="20">
<Button Style="{StaticResource RedButtonStyle}" Content="Red Button" />
<CheckBox Style="{StaticResource YellowCheckBoxStyle}" Content="Yellow CheckBox" />
<RadioButton Style="{StaticResource OrangeRadioButtonStyle}" Content="Orange RadioButton" />
<Button Style="{StaticResource GreenButtonStyle}" Content="Green Button" />
</StackPanel>
</Grid>
Tuesday, August 11, 2009
Five Minute Silverlight 3 Aides-Memoire #5 – Based on Styles
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment