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

728x90
반응형
728x170

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 엘리먼트 정의하기"
    Background="Black"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <Path x:Key="ToggleFullScreenIconPathKey"
            Data="
                M         9.6560059 19.516005 L         12.484985 22.345999 6.414978  28.413002 10        32
                0         32        0         21.999998 3.5849915 25.585007 z         M         22.342987 19.512999
                L         28.412994 25.585007 32        21.999998 32        32        22        32        25.584991
                28.413002 19.513    22.345999 z         M         22        0         L         32        0
                32        10.000001 28.414978 6.4129991 22.342987 12.486002 19.513    9.6559991 25.584991 3.5849995
                z         M         0         0         L         10        0         6.414978  3.5849995 12.483978
                9.6569986 9.6569824 12.485002 3.5849915 6.4129991 0         10.000001 z" />
        <SolidColorBrush x:Key="CustomButtonHighlightSolidColorBrushKey" Color="#ffefefef" />
        <Style x:Key="ModernButtonStyleKey" TargetType="{x:Type Button}">
            <Setter Property="Width"           Value="45"/>
            <Setter Property="Height"          Value="45"/>
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Padding"         Value="12"/>
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Foreground" Value="{StaticResource CustomButtonHighlightSolidColorBrushKey}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border
                            BorderThickness="0"
                            Padding="{TemplateBinding Padding}"
                            Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="contentPresenter"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#22ffffff" />
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#44ffffff" />
                </Trigger>
            </Style.Triggers>
        </Style>    
    </Window.Resources>
    <Grid>
        <Button Style="{DynamicResource ModernButtonStyleKey}">
            <Path
                Stretch="Uniform"
                Data="{Binding Source={StaticResource ToggleFullScreenIconPathKey}, Path=Data}"
                Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" />
        </Button>
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요