첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
0.01MB

▶ 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="ButtonTemplateKey" TargetType="Button">
            <Grid>
                <Ellipse Name="ButtonEllipse"
                    Width="150"
                    Height="100">
                    <Ellipse.Fill>
                        <LinearGradientBrush
                            StartPoint="0 0.2"
                            EndPoint="0.2 1.4">
                            <GradientStop Offset="0" Color="Red"    />
                            <GradientStop Offset="1" Color="Orange" />
                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <ContentPresenter
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Content="{TemplateBinding Content}" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="ButtonEllipse" Property="Fill">
                        <Setter.Value>
                            <LinearGradientBrush
                                StartPoint="0 0.2"
                                EndPoint="0.2 1.4">
                                <GradientStop Offset="0" Color="YellowGreen" />
                                <GradientStop Offset="1" Color="Gold"        />
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="RenderTransform">
                        <Setter.Value>
                            <ScaleTransform
                                ScaleX="0.8"
                                ScaleY="0.8"   
                                CenterX="0"
                                CenterY="0" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="RenderTransformOrigin" Value="0.5 0.5" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    <Grid>
        <Button
            Template="{StaticResource ButtonTemplateKey}"
            FontSize="32"
            FontWeight="Bold"
            Content="Run" />
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker
TAG , ,

댓글을 달아 주세요