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

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

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


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 엘리먼트 : Button 엘리먼트 정의하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Window.Resources>

        <ControlTemplate x:Key="ButtonControlTemplateKey" TargetType="Button">

            <Grid>

                <Ellipse>

                    <Ellipse.Fill>

                        <LinearGradientBrush

                            StartPoint="0.5 0"

                            EndPoint="0.5 1">

                            <GradientStop Color="Yellow" Offset="0" />

                            <GradientStop Color="Red"    Offset="1" />

                        </LinearGradientBrush>

                    </Ellipse.Fill>

                </Ellipse>

                <ContentPresenter

                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"

                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"

                    Margin="{TemplateBinding Padding}"

                    ContentTemplate="{TemplateBinding ContentTemplate}"

                    Content="{TemplateBinding Content}" />

            </Grid>

        </ControlTemplate>

    </Window.Resources>

    <Grid>

        <Button

            Template="{StaticResource ButtonControlTemplateKey}"

            HorizontalAlignment="Center"

            VerticalAlignment="Center"

            Width="100"

            Height="100"

            FontWeight="Bold"

            Content="버튼" />

    </Grid>

</Window>

 

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

Posted by 사용자 icodebroker

댓글을 달아 주세요