스타일(Style) : 재 사용 가능한 속성 집합
[MainPage.xaml]
<UserControl x:Class="RiaStyle.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<!--[1] 스타일 정의 -->
<Grid.Resources>
<!--[a] 단순 속성-->
<Style x:Key="myButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Yellow" />
<Setter Property="Foreground" Value="Blue" />
</Style>
<!--[b] 복합 속성-->
<Style x:Key="myRectStyle" TargetType="Rectangle">
<Setter Property="Stroke" Value="Black" />
<Setter Property="StrokeThickness" Value="5" />
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Red" Offset="0.0"></GradientStop>
<GradientStop Color="Blue" Offset="1.0"></GradientStop>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<!--[2] 스타일 사용-->
<StackPanel>
<Button Content="스타일이 적용된 버튼" Style="{StaticResource myButtonStyle}" />
<Button Content="스타일이 적용된 버튼" />
<Rectangle Width="100" Height="100" Style="{StaticResource myRectStyle}"></Rectangle>
<Rectangle Width="50" Height="50" Style="{StaticResource myRectStyle}"></Rectangle>
</StackPanel>
</Grid>
</UserControl>