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

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 엘리먼트 : ToggleButton 엘리먼트 정의하기"
    Background="Black"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
    <Path x:Key="InformationIconPathKey"
        Data="
            M          11.331985 10.669     C         11.137986 10.669    10.976986 10.731    10.852986 10.855999
            10.728987  10.981    10.665987  11.141    10.665987 11.335    L         10.665987 14.668    C
            10.665987  14.862    10.727986  15.021999 10.852986 15.146999 10.977986 15.271999 11.136986 15.334
            11.331985  15.334    L          13.331984 15.334    13.331984 22        11.331985 22        C
            11.137986  22        10.976986  22.063    10.852986 22.188    10.728987 22.313    10.665987 22.471999
            10.665987  22.667    L          10.665987 26        C         10.665987 26.195    10.727986 26.354
            10.852986  26.479    10.977986  26.604    11.136986 26.667    11.331985 26.667    L         20.665975
            26.667     C         20.860975  26.667    21.019974 26.604    21.144974 26.479    21.269974 26.354
            21.332974  26.193999 21.332974  26        L         21.330974 26.002    21.330974 22.667999 C
            21.330974  22.474    21.267974  22.313999 21.143974 22.188999 21.019974 22.063999 20.859975 22.002
            20.664975  22.002    L          18.665977 22.002    18.665977 11.335    C         18.665977 11.141
            18.602977  10.981    18.477977  10.855999 18.352978 10.731    18.192978 10.669    17.998978 10.669
            z          M         13.999983  3.3329997 C         13.805983 3.3329997 13.646983 3.3959994 13.520984
            3.5209994  13.394983 3.6459994  13.332984 3.8049994 13.332984 3.9999995 L         13.332984 7.3329997
            C          13.332984 7.5269995  13.395984 7.6879995 13.520984 7.8119993 13.645983 7.9359996 13.805983
            7.9989996  13.999983 7.9989996  L         17.999978 7.9989996 C         18.194978 7.9989996 18.353978
            7.9369996  18.478977 7.8119993  18.603977 7.6869996 18.666977 7.5269995 18.666977 7.3329997 L
            18.666977  3.9999995 C          18.666977 3.8049994 18.603977 3.6459994 18.478977 3.5209994 18.353978
            3.3959994  18.193978 3.3329997  17.999978 3.3329997 z         M         15.99998  0         C
            18.902977  0         21.579974  0.7149992 24.030971 2.1459999 26.481968 3.5769997 28.422966 5.5179996
            29.853964  7.9689994 L          29.855964 7.9689994 C         31.285962 10.42     32.000961 13.097
            32.000961  16        32.000961  18.901999 31.285962 21.58     29.854964 24.030999 28.423966 26.482
            26.482968  28.424    24.031971  29.854    21.579974 31.285    18.901977 32        15.99998  32
            13.097983  32        10.419987  31.285    7.9689894 29.854    5.517992  28.423    3.5769958 26.482
            2.1459961  24.030999 0.71499825 21.58     0         18.901999 0         16        0         13.098
            0.71499825 10.421    2.1459961  7.9689994 3.5769958 5.5169997 5.517992  3.5769997 7.9689894 2.1459999
            10.419987  0.7149992 13.096984  0         15.99998  0         z" />
        <SolidColorBrush x:Key="CustomToggleButtonHighlightSolidColorBrushKey" Color="#ffefefef" />
        <Style x:Key="CustomToggleButtonStyleKey" TargetType="ToggleButton">
            <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 CustomToggleButtonHighlightSolidColorBrushKey}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <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>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Background" Value="#44ffffff" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <ToggleButton
            Style="{DynamicResource CustomToggleButtonStyleKey}"
            ToolTip="Information">
            <Path
                Stretch="Uniform"
                Data="{Binding Source={StaticResource InformationIconPathKey}, Path=Data}"
                Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}}" />
        </ToggleButton>
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요