첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ ControlTemplate 엘리먼트를 사용해 Calendar 엘리먼트를 정의하는 방법을 보여준다.

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="TestProject"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <Color x:Key="SelectedBackgroundColorKey">#ffc5cbf9</Color>
        <Color x:Key="ControlLightColorKey">White</Color>
        <Color x:Key="ControlMediumColorKey">#ff7381f9</Color>
        <Color x:Key="ControlMouseOverColorKey">#ff3843c4</Color>
        <Color x:Key="GlyphColorKey">#ff444444</Color>
        <Color x:Key="GlyphMouseOverColorKey">sc#1, 0.004391443, 0.002428215, 0.242281124</Color>
        <Color x:Key="BorderLightColorKey">#ffcccccc</Color>
        <Color x:Key="BorderDarkColorKey">#ff444444</Color>
        <Color x:Key="HeaderTopColorKey">#ffc5cbf9</Color>
        <Style x:Key="CalendarDayButtonStyleKey" TargetType="CalendarDayButton">
            <Setter Property="MinWidth"                   Value="5"      />
            <Setter Property="MinHeight"                  Value="5"      />
            <Setter Property="FontSize"                   Value="16"     />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment"   Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CalendarDayButton">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.1" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Normal" />
                                    <VisualState Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="highlightBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="highlightBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="highlightBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0" />
                                            <DoubleAnimation
                                                Storyboard.TargetName="normalTextContentPresenter"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.35" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="SelectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Unselected" />
                                    <VisualState Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="selectedBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.75" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="CalendarButtonFocusStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="CalendarButtonFocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetName="dayButtonFocusVisualRectangle"
                                                Storyboard.TargetProperty="Visibility"
                                                Duration="0">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState Name="CalendarButtonUnfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetName="dayButtonFocusVisualRectangle"
                                                Storyboard.TargetProperty="Visibility"
                                                Duration="0">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="ActiveStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Active" />
                                    <VisualState Name="Inactive">
                                        <Storyboard>
                                            <ColorAnimation
                                                Storyboard.TargetName="normalTextContentPresenter"
                                                Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                Duration="0"
                                                To="#ff777777" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="DayStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="RegularDay" />
                                    <VisualState Name="Today">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="todayBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="1" />
                                            <ColorAnimation
                                                Storyboard.TargetName="normalTextContentPresenter"
                                                Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                Duration="0"
                                                To="#ffffffff" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="BlackoutDayStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="NormalDay" />
                                    <VisualState Name="BlackoutDay">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="blackoutPath"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.2" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle Name="todayBackgroundRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                Opacity="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle Name="selectedBackgroundRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                Opacity="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <Border
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}" />
                            <Rectangle Name="highlightBackgroundRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                Opacity="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource ControlMouseOverColorKey}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Name="normalTextContentPresenter"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Margin="5 1 5 1">
                                <TextElement.Foreground>
                                    <SolidColorBrush Color="#ff333333" />
                                </TextElement.Foreground>
                            </ContentPresenter>
                            <Path Name="blackoutPath"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Margin="3"
                                Opacity="0"
                                RenderTransformOrigin="0.5 0.5"
                                Fill="#ff000000"
                                Stretch="Fill"
                                Data="M 8.1772461 11.029181 L 10.433105
                                      11.029181 L 11.700684 12.801641 L 12.973633
                                      11.029181 L 15.191895 11.029181 L 12.844727
                                      13.999395 L 15.21875  17.060919 L 12.962891
                                      17.060919 L 11.673828 15.256231 L 10.352539
                                      17.060919 L 8.1396484 17.060919 L 10.519043
                                      14.042364 z" />
                            <Rectangle Name="dayButtonFocusVisualRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                IsHitTestVisible="false"
                                Visibility="Collapsed">
                                <Rectangle.Stroke>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Stroke>
                            </Rectangle>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="CalendarButtonStyleKey" TargetType="CalendarButton">
            <Setter Property="MinWidth"                   Value="40"     />
            <Setter Property="MinHeight"                  Value="42"     />
            <Setter Property="FontSize"                   Value="16"     />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment"   Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CalendarButton">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.1" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Normal" />
                                    <VisualState Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="backgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="backgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="SelectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Unselected" />
                                    <VisualState Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="selectedBackgroundRectangle"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="0.75" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="ActiveStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="Active" />
                                    <VisualState Name="Inactive">
                                        <Storyboard>
                                            <ColorAnimation
                                                Storyboard.TargetName="normalTextContentPresenter"
                                                Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                Duration="0"
                                                To="#ff777777" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup Name="CalendarButtonFocusStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0" />
                                    </VisualStateGroup.Transitions>
                                    <VisualState Name="CalendarButtonFocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetName="calendarButtonFocusVisualRectangle"
                                                Storyboard.TargetProperty="Visibility"
                                                Duration="0">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState Name="CalendarButtonUnfocused" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle Name="selectedBackgroundRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                Opacity="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle Name="backgroundRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                Opacity="0">
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Name="normalTextContentPresenter"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Margin="1 0 1 1">
                                <TextElement.Foreground>
                                    <SolidColorBrush Color="#ff333333" />
                                </TextElement.Foreground>
                            </ContentPresenter>
                            <Rectangle Name="calendarButtonFocusVisualRectangle"
                                RadiusX="1"
                                RadiusY="1"
                                IsHitTestVisible="false"
                                Visibility="Collapsed">
                                <Rectangle.Stroke>
                                    <SolidColorBrush Color="{DynamicResource SelectedBackgroundColorKey}" />
                                </Rectangle.Stroke>
                            </Rectangle>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Background">
                <Setter.Value>
                    <SolidColorBrush Color="{DynamicResource ControlMediumColorKey}" />
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="PreviousButtonTemplateKey" TargetType="{x:Type Button}">
            <Grid Cursor="Hand">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup Name="CommonStates">
                        <VisualState Name="Normal" />
                        <VisualState Name="MouseOver">
                            <Storyboard>
                                <ColorAnimation
                                    Storyboard.TargetName="path"
                                    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                    To="{DynamicResource GlyphMouseOverColorKey}"
                                    Duration="0" />
                            </Storyboard>
                        </VisualState>
                        <VisualState Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetName="path"
                                    Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
                                    Duration="0"
                                    To="0.5" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid Background="Transparent">
                    <Path Name="path"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        Margin="14 -6 0 0"
                        Width="6"
                        Height="10"
                        Stretch="Fill"
                        Data="M 288.75 232.25 L 288.75 240.625 L 283 236.625 z">
                        <Path.Fill>
                            <SolidColorBrush Color="{DynamicResource GlyphColorKey}" />
                        </Path.Fill>
                    </Path>
                </Grid>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="NextButtonTemplateKey" TargetType="{x:Type Button}">
            <Grid Cursor="Hand">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup Name="CommonStates">
                        <VisualState Name="Normal" />
                        <VisualState Name="MouseOver">
                            <Storyboard>
                                <ColorAnimation
                                    Storyboard.TargetName="path"
                                    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                    Duration="0"
                                    To="{StaticResource GlyphMouseOverColorKey}" />
                            </Storyboard>
                        </VisualState>
                        <VisualState Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetName="path"
                                    Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
                                    Duration="0"
                                    To="0.5" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid Background="Transparent">
                    <Path Name="path"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Margin="0 -6 14 0"
                        Width="6"
                        Height="10"
                        Stretch="Fill"
                        Data="M 282.875 231.875 L 282.875 240.375 L 288.625 236 z">
                        <Path.Fill>
                            <SolidColorBrush Color="{DynamicResource GlyphColorKey}" />
                        </Path.Fill>
                    </Path>
                </Grid>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="HeaderButtonTemplateKey" TargetType="{x:Type Button}">
            <Grid Cursor="Hand">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup Name="CommonStates">
                        <VisualState Name="Normal" />
                        <VisualState Name="MouseOver">
                            <Storyboard>
                                <ColorAnimation
                                    Storyboard.TargetName="buttonContentPresenter"
                                    Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                    Duration="0"
                                    To="{DynamicResource GlyphMouseOverColorKey}" />
                            </Storyboard>
                        </VisualState>
                        <VisualState Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetName="buttonContentPresenter"
                                    Storyboard.TargetProperty="Opacity"
                                    Duration="0"
                                    To="0.5" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <ContentPresenter Name="buttonContentPresenter"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="1 4 1 9"
                    TextElement.Foreground="#ff333333"
                    Content="{TemplateBinding Content}" />
            </Grid>
        </ControlTemplate>
        <Style x:Key="CalendarItemStyleKey" TargetType="{x:Type CalendarItem}">
            <Setter Property="Margin" Value="0 3 0 3" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type CalendarItem}">
                        <ControlTemplate.Resources>
                            <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Margin="0 6 0 6"
                                    Foreground="#ff333333"
                                    FontFamily="Verdana"
                                    FontSize="16"
                                    FontWeight="Bold"
                                    Text="{Binding}" />
                            </DataTemplate>
                        </ControlTemplate.Resources>
                        <Grid Name="PART_Root">
                            <Grid.Resources>
                                <SolidColorBrush x:Key="DisabledColor" Color="#a5ffffff" />
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup Name="CommonStates">
                                    <VisualState Name="Normal" />
                                    <VisualState Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation
                                                Storyboard.TargetName="PART_DisabledVisual"
                                                Storyboard.TargetProperty="Opacity"
                                                Duration="0"
                                                To="1" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border
                                CornerRadius="1"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}">
                                <Border
                                    CornerRadius="1"
                                    BorderThickness="2"
                                    BorderBrush="#FFFFFFFF">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*"    />
                                        </Grid.RowDefinitions>
                                        <Button Name="PART_PreviousButton" Grid.Row="0" Grid.Column="0"
                                            Template="{StaticResource PreviousButtonTemplateKey}"
                                            HorizontalAlignment="Left"
                                            Width="28"
                                            Height="20"
                                            Focusable="False" />
                                        <Button Name="PART_HeaderButton" Grid.Row="0" Grid.Column="1"
                                            Template="{StaticResource HeaderButtonTemplateKey}"
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            FontWeight="Bold"
                                            Focusable="False"
                                            FontSize="16" />
                                        <Button Name="PART_NextButton" Grid.Row="0" Grid.Column="2"
                                            Template="{StaticResource NextButtonTemplateKey}"
                                            HorizontalAlignment="Right"
                                            Width="28"
                                            Height="20"
                                            Focusable="False" />
                                        <Grid Name="PART_MonthView" Grid.Row="1" Grid.ColumnSpan="3"
                                            HorizontalAlignment="Center"
                                            Margin="6 -1 6 6"
                                            Visibility="Visible">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                        </Grid>
                                        <Grid Name="PART_YearView" Grid.Row="1" Grid.ColumnSpan="3"
                                            HorizontalAlignment="Center"
                                            Margin="6 -3 7 6"
                                            Visibility="Hidden">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                        </Grid>
                                    </Grid>
                                </Border>
                            </Border>
                            <Rectangle Name="PART_DisabledVisual"
                                 RadiusY="2"
                                 RadiusX="2"
                                 Fill="{StaticResource DisabledColor}"
                                 StrokeThickness="1"
                                 Stroke="{StaticResource DisabledColor}"
                                 Stretch="Fill"
                                 Opacity="0"
                                 Visibility="Collapsed" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter
                                    TargetName="PART_DisabledVisual"
                                    Property="Visibility"
                                    Value="Visible" />
                            </Trigger>
                            <DataTrigger
                                Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
                                Value="Year">
                                <Setter
                                    TargetName="PART_MonthView"
                                    Property="Visibility"
                                    Value="Hidden" />
                                <Setter
                                    TargetName="PART_YearView"
                                    Property="Visibility"
                                    Value="Visible" />
                            </DataTrigger>
                            <DataTrigger
                                Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
                                Value="Decade">
                                <Setter
                                    TargetName="PART_MonthView"
                                    Property="Visibility"
                                    Value="Hidden" />
                                <Setter
                                    TargetName="PART_YearView"
                                    Property="Visibility"
                                    Value="Visible" />
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="CalendarStyleKey" TargetType="{x:Type Calendar}">
            <Setter Property="CalendarButtonStyle"    Value="{StaticResource CalendarButtonStyleKey   }" />
            <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyleKey}" />
            <Setter Property="CalendarItemStyle"      Value="{StaticResource CalendarItemStyleKey     }" />
            <Setter Property="Foreground"             Value="#ff333333"                                  />
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush
                        StartPoint="0.5 0"
                        EndPoint="0.5 1">
                        <GradientStop Offset="0"    Color="{DynamicResource HeaderTopColorKey}"     />
                        <GradientStop Offset="0.16" Color="{DynamicResource ControlMediumColorKey}" />
                        <GradientStop Offset="0.16" Color="{DynamicResource ControlLightColorKey}"  />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush
                        StartPoint="0 0"
                        EndPoint="0 1">
                        <GradientStop Offset="0" Color="{DynamicResource BorderLightColorKey}" />
                        <GradientStop Offset="1" Color="{DynamicResource BorderDarkColorKey}"  />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Calendar}">
                        <StackPanel Name="PART_Root"
                            HorizontalAlignment="Center">
                            <CalendarItem Name="PART_CalendarItem"
                                Style="{TemplateBinding CalendarItemStyle}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}" />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <StackPanel
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Orientation="Horizontal">
        <Calendar
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Margin="10" />
        <Calendar
            Style="{StaticResource CalendarStyleKey}"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Margin="10" />
    </StackPanel>
</Window>
728x90
그리드형(광고전용)
Posted by icodebroker
,