스타일(Style) : 재 사용 가능한 속성 집합
.NET프로그래밍/Silverlight 3.0 2009. 12. 3. 09:46 |[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>
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
애니메이션 (Animation) (0) | 2009.12.03 |
---|---|
템플릿(Template) : 컨트롤 모양 미리 정의 (0) | 2009.12.03 |
리소스 (Resource) (0) | 2009.12.03 |
DatePicker 컨트롤 (0) | 2009.12.02 |
Calendar 컨트롤 (0) | 2009.12.02 |