첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ ControlTemplate 엘리먼트 : Button 엘리먼트 정의하기

----------------------------------------------------------------------------------------------------

<Button

    HorizontalAlignment="Center"

    VerticalAlignment="Center"

    Padding="20"

    FontSize="48">

    Button with Custom Template

    <Button.Template>

        <ControlTemplate>

            <Border

                Name="border"

                BorderThickness="3"

                BorderBrush="Red"

                Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">

                <TextBlock

                    Name="textBlock"

                    Margin="{TemplateBinding Control.Padding}"

                    FontStyle="Italic"

                    Text="{TemplateBinding ContentControl.Content}" />

            </Border>

            <ControlTemplate.Triggers>

                <Trigger

                    Property="UIElement.IsMouseOver"

                    Value="True">

                    <Setter TargetName="border"    Property="Border.CornerRadius"  Value="24"   />

                    <Setter TargetName="textBlock" Property="TextBlock.FontWeight" Value="Bold" />

                </Trigger>

                <Trigger

                    Property="Button.IsPressed"

                    Value="True">

                    <Setter

                        TargetName="border"

                        Property="Border.Background"

                        Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />

                </Trigger>

            </ControlTemplate.Triggers>

        </ControlTemplate>

    </Button.Template>

</Button>

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요