ButtonStyles.xaml:
<ResourceDictionary
x:Name="ButtonsStyles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style x:Key="RedButton" TargetType="Button">
<Setter Property="Foreground" Value="Red" />
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="100" />
<Setter Property="Margin" Value="10" />
</Style>
<Style x:Key="GreenButton" TargetType="Button">
<Setter Property="Foreground" Value="Green" />
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="100" />
<Setter Property="Margin" Value="10" />
</Style>
</ResourceDictionary>
CheckBoxStyles.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="CheckBoxStyles"
>
<Style x:Key="YellowCheckBox" TargetType="CheckBox">
<Setter Property="Foreground" Value="Yellow" />
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="10" />
</Style>
<Style x:Key="OrangeCheckBox" TargetType="CheckBox">
<Setter Property="Foreground" Value="Orange" />
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="10" />
</Style>
</ResourceDictionary>
MainPage.xaml:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ButtonStyles.xaml" />
<ResourceDictionary Source="CheckBoxStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</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="Horizontal">
<Button Grid.Row="0" Grid.Column="0" Style="{StaticResource RedButton}" Content="Red Button" />
<Button Grid.Row="0" Grid.Column="1" Style="{StaticResource GreenButton}" Content="Green Button" />
<CheckBox Grid.Row="1" Grid.Column="0" Style="{StaticResource YellowCheckBox}" Content="Yellow CheckBox" />
<CheckBox Grid.Row="1" Grid.Column="1" Style="{StaticResource OrangeCheckBox}" Content="Orange CheckBox" />
</StackPanel>
</Grid>
No comments:
Post a Comment