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

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

<Grid x:Name="grid">

    <Grid.Resources>

        <ControlTemplate

            x:Key="ControlTemplateKey"

            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

                    x:Name="contentPresenter"

                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"

                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"

                    Margin="{TemplateBinding Padding}"

                    ContentTemplate="{TemplateBinding ContentTemplate}"

                    Content="{TemplateBinding Content}" />

            </Grid>

        </ControlTemplate>

    </Grid.Resources>

    <Button

        Width="100"

        Height="50"

        Template="{StaticResource ControlTemplateKey}"

        FontSize="12"

        FontWeight="Bold"

        Content="버튼" />

</Grid>

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

Posted by 사용자 icodebroker

댓글을 달아 주세요