■ TemplateBinding 태그 확장 사용하기

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

<Button

    HorizontalAlignment="Center"

    VerticalAlignment="Center"

    Padding="20"

    FontSize="48">

    커스텀 템플리트 버튼

    <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