728x90
반응형
728x170
■ ControlTemplate 엘리먼트를 사용해 RadioButton 엘리먼트를 정의하는 방법을 보여준다.
▶ 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="ControlTemplate 엘리먼트 : RadioButton 엘리먼트 정의하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<ControlTemplate x:Key="RadioButtonTemplateKey" TargetType="{x:Type RadioButton}">
<Border Name="border"
BorderBrush="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
CornerRadius="100"
Padding="10">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="BorderThickness" Value="3" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<GroupBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
Header="옵션"
Padding="5">
<StackPanel>
<RadioButton
Template="{StaticResource RadioButtonTemplateKey}"
HorizontalAlignment="Center"
Margin="10"
Content="라디오 버튼 1" />
<RadioButton
Template="{StaticResource RadioButtonTemplateKey}"
HorizontalAlignment="Center"
Margin="10"
Content="라디오 버튼 2" />
<RadioButton
Template="{StaticResource RadioButtonTemplateKey}"
HorizontalAlignment="Center"
Margin="10"
IsChecked="True"
Content="라디오 버튼 3" />
<RadioButton
Template="{StaticResource RadioButtonTemplateKey}"
HorizontalAlignment="Center"
Margin="10"
Content="라디오 버튼 4" />
<RadioButton
Template="{StaticResource RadioButtonTemplateKey}"
HorizontalAlignment="Center"
Margin="10"
Content="라디오 버튼 5" />
</StackPanel>
</GroupBox>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] XmlDataProvider 엘리먼트 : x:XData 엘리먼트를 사용해 XML 데이터 내장하기 (0) | 2020.08.26 |
---|---|
[C#/WPF] ItemsPanelTemplate 엘리먼트 : ListBox 엘리먼트의 ItemPanel 속성에 커스텀 패널 설정하기 (0) | 2020.08.26 |
[C#/WPF] DataTemplate 엘리먼트 : ListBox 엘리먼트의 ItemTemplate 속성 설정하기 (0) | 2020.08.26 |
[C#/WPF] DataTemplate 엘리먼트 : Button 엘리먼트의 ContentTemplate 속성 설정하기 (0) | 2020.08.26 |
[C#/WPF] ControlTemplate 엘리먼트 : CheckBox 엘리먼트 정의하기 (0) | 2020.08.26 |
[C#/WPF] 지오메트리 사용하기 (0) | 2020.08.26 |
[C#/WPF] ControlTemplate 엘리먼트 : RadioButton 엘리먼트 정의하기 (0) | 2020.08.25 |
[C#/WPF] LinearGradientBrush 엘리먼트 : 글래스 효과 브러시 만들기 (0) | 2020.08.25 |
[C#/WPF] DrawingBrush 엘리먼트 : GeometryDrawing 객체를 사용해 격자 배경 브러시 만들기 (0) | 2020.08.25 |
[C#/WPF] UIElement 클래스 : PreviewDragOver/PreviewDrop 이벤트를 사용해 파일 드래그 & 드롭 사용하기 (0) | 2020.08.25 |
댓글을 달아 주세요