728x90
반응형
728x170
■ Style 엘리먼트의 TargetType 속성을 사용해 버튼 스타일을 설정하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="Style 엘리먼트 : TargetType 속성을 사용해 버튼 스타일 설정하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="10" />
<Setter Property="FontSize" Value="24" />
<Setter Property="Foreground" Value="Blue" />
</Style>
</Window.Resources>
<Grid>
<Button
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="10"
Content="테스트" />
</Grid>
</Window>
※ x:Type 태그 확장을 사용하지 않아도 된다.
※ 리소스 설정시 TargetType 특성을 사용하는 경우 x:Key 특성을 사용하지 않아도 된다.
※ TargetType 특성을 사용하면 Setter 엘리먼트 Property 특성 지정시 "클래스.속성"을 "속성"만 나열해도 된다.
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] DataTrigger 엘리먼트 사용하기 (0) | 2014.01.14 |
---|---|
[C#/WPF] MultiTrigger 엘리먼트 사용하기 (0) | 2014.01.14 |
[C#/WPF] Trigger 엘리먼트 사용하기 (0) | 2014.01.14 |
[C#/WPF] Style 엘리먼트 : BasedOn 속성을 사용해 TargetType 속성 값으로 정의한 버튼 타입 스타일 상속하기 (0) | 2014.01.14 |
[C#/WPF] Sytle 클래스 : BasedOn 속성 사용하기 (0) | 2014.01.14 |
[C#/WPF] Setter 엘리먼트 : Value 속성 값으로 NULL 값 설정하기 (0) | 2014.01.14 |
[C#/WPF] Setter 엘리먼트 사용하기 (0) | 2014.01.14 |
[C#/WPF] Style 엘리먼트 사용하기 (0) | 2014.01.13 |
[C#/WPF] BindingExpression 클래스 : UpdateSourceTrigger.Explicit 설정시 처리하기 (0) | 2014.01.13 |
[C#/WPF] VisualTreeHelper 클래스 : 비주얼 찾기 (0) | 2014.01.13 |
댓글을 달아 주세요