첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ ControlTemplate 엘리먼트를 사용해 RadioButton 엘리먼트를 정의하는 방법을 보여준다.

TestProject.zip
다운로드

▶ 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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요