|
|
|
|
<Window x:Class="HowToUseStyle.MainWindow"
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:local="clr-namespace:HowToUseStyle"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
Title="MainWindow" Height="450" Width="800">
|
|
|
|
|
<Window.Resources>
|
|
|
|
|
<!--Style Inheritance-->
|
|
|
|
|
<Style TargetType="{x:Type Button}" x:Key="styBoldButton">
|
|
|
|
|
<Setter Property="FontWeight" Value="ExtraBold"/>
|
|
|
|
|
</Style>
|
|
|
|
|
<Style TargetType="Button" BasedOn="{StaticResource styBoldButton}">
|
|
|
|
|
<Setter Property="Background" Value="Tomato"/>
|
|
|
|
|
<Setter Property="FontSize" Value="30"/>
|
|
|
|
|
</Style>
|
|
|
|
|
<Style TargetType="Button" x:Key="rscButton" BasedOn="{StaticResource styBoldButton}">
|
|
|
|
|
<Setter Property="Background" Value="PaleVioletRed"/>
|
|
|
|
|
</Style>
|
|
|
|
|
</Window.Resources>
|
|
|
|
|
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<Button Grid.Row="0" Content="This is button"/>
|
|
|
|
|
<Button Grid.Row="1" Content="This is button" Style="{StaticResource rscButton}"/>
|
|
|
|
|
<Button Grid.Row="2" Content="Trigger button">
|
|
|
|
|
<Button.Style>
|
|
|
|
|
<Style TargetType="Button">
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
|
|
|
<Setter Property="Background" Value="LimeGreen"/>
|
|
|
|
|
<Setter Property="Foreground" Value="White"/>
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</Button.Style>
|
|
|
|
|
</Button>
|
|
|
|
|
<StackPanel Grid.Row="3" Orientation="Horizontal">
|
|
|
|
|
<CheckBox x:Name="cbTrigger"/>
|
|
|
|
|
<Button Content="Check the check box">
|
|
|
|
|
<Button.Style>
|
|
|
|
|
<Style TargetType="Button">
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding ElementName=cbTrigger, Path=IsChecked}" Value="True">
|
|
|
|
|
<Setter Property="Foreground" Value="Red"/>
|
|
|
|
|
<Setter Property="FontWeight" Value="ExtraBold"/>
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</Button.Style>
|
|
|
|
|
</Button>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Window>
|