<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
                    xmlns:smart="clr-namespace:SmartUI.Controls"
                    xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib">
   
    <!--日历主体样式表-->
    <Style x:Key="CalendarDefaultItemStyle" TargetType="{x:Type CalendarItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarItem}">
                    <ControlTemplate.Resources>
                        <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                            <!--日历星期几的绑定样式,我格式化成周一,周二等-->
                            <TextBlock Foreground="#666666" FontSize="16" FontFamily="微软雅黑" HorizontalAlignment="Center" Margin="0 15" Text="{Binding}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </ControlTemplate.Resources>
                    <Grid x:Name="PART_Root">
                        <Grid.Resources>
                            <!--设置日历控件 IsEnable=false 时的不可用遮罩层颜色,并且会播放过渡动画-->
                            <SolidColorBrush x:Key="DisabledColor" Color="#A5FFFFFF" />
                        </Grid.Resources>
                        <Grid>
                            <Grid.Resources>
                                <!--日历头左箭头按钮样式模版-->
                                <ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}">
                                    <!--鼠标悬停在左箭头按钮上时改变鼠标指针样式-->
                                    <Grid Cursor="Hand">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <!--鼠标悬停在左箭头按钮上时左箭头颜色变化动画-->
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                                     To="#FF409EFF"
                                                                                     Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                                                     Storyboard.TargetName="path" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0" To=".5"
                                                                                      Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
                                                                                      Storyboard.TargetName="path" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Grid Background="Transparent">
                                            <!--左箭头-->
                                            <Path x:Name="path"
                                                               Data="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z"
                                                               Fill="#999999"
                                                               HorizontalAlignment="Left"
                                                               Height="14"
                                                               Width="14"
                                                               Margin="10,0,0,0"
                                                               Stretch="Fill"
                                                               VerticalAlignment="Center" />
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                                <!--日历头右箭头按钮样式模版,这块跟左箭头样式模版没什么区别-->
                                <ControlTemplate x:Key="NextButtonTemplate"
                                                              TargetType="{x:Type Button}">
                                    <Grid Cursor="Hand">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                                      To="#FF409EFF"
                                                                                     Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                                                     Storyboard.TargetName="path" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                                      To=".5"
                                                                                      Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
                                                                                      Storyboard.TargetName="path" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Grid Background="Transparent">
                                            <Path x:Name="path"
                                                               Data="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"
                                                               Fill="#999999"
                                                               HorizontalAlignment="Right"
                                                               Height="14"
                                                               Width="14"
                                                               Margin="0,0,10,0"
                                                               Stretch="Fill"
                                                               VerticalAlignment="Center" />
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                                <!--日历头中间年按钮样式模版-->
                                <ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
                                    <Grid Cursor="Hand">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0" To="#FF409EFF"
                                                                                     Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                                                     Storyboard.TargetName="buttonContent" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                                      To=".5"
                                                                                      Storyboard.TargetProperty="Opacity"
                                                                                      Storyboard.TargetName="buttonContent" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <ContentPresenter x:Name="buttonContent" Height="{TemplateBinding Height}"
                                                                       ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                       Content="{TemplateBinding Content}"
                                                                       TextElement.Foreground="#999999"
                                                                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                       Margin="1,14,1,4"
                                                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                    </Grid>
                                </ControlTemplate>
                            </Grid.Resources>

                            <Grid.RowDefinitions>
                                <!--日历头,左箭头,年,右箭头-->
                                <RowDefinition Height="48" />
                                <!--日历内容,星期几和具体的日期几号几号-->
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <!--左箭头-->
                                <ColumnDefinition Width="48" />
                                <!--年-->
                                <ColumnDefinition Width="*" />
                                <!--右箭头-->
                                <ColumnDefinition Width="48" />
                            </Grid.ColumnDefinitions>
                            <Border BorderBrush="#CFCFCF" BorderThickness="1 1 1 0" Grid.ColumnSpan="3"/>
                            <!--左箭头-->
                            <Button x:Name="PART_PreviousButton"
                                                 Grid.Column="0"
                                                 Focusable="False"
                                                 HorizontalAlignment="Left"
                                                 Grid.Row="0"
                                                 Template="{StaticResource PreviousButtonTemplate}" />
                            <!--年-->
                            <Button x:Name="PART_HeaderButton"
                                                 Grid.Column="1"
                                                 FontFamily="微软雅黑"
                                                 Focusable="False"
                                                 FontSize="18"
                                                 HorizontalAlignment="Center" Height="48"
                                                 Grid.Row="0" VerticalContentAlignment="Center"
                                                 Template="{StaticResource HeaderButtonTemplate}"
                                                 VerticalAlignment="Center" />
                            <!--右箭头-->
                            <Button x:Name="PART_NextButton"
                                                 Grid.Column="2"
                                                 Focusable="False"
                                                 HorizontalAlignment="Right"
                                                 Grid.Row="0"
                                                 Template="{StaticResource NextButtonTemplate}" />
                            <!--日期几号几号内容显示-->
                            <Border Grid.Row="1"
                                                 Grid.ColumnSpan="3"
                                                 Margin="0"
                                                 BorderBrush="#cfcfcf"
                                                 BorderThickness="1,0,1,1">
                                <Grid x:Name="PART_MonthView"
                                                   HorizontalAlignment="Center"
                                                   Visibility="Visible">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                </Grid>
                            </Border>

                            <!--月和年内容显示-->
                            <Grid x:Name="PART_YearView"
                                               Grid.ColumnSpan="3"
                                               HorizontalAlignment="Center"
                                               Margin="6,-3,7,6"
                                               Grid.Row="1"
                                               Visibility="Hidden"
                                               VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                            </Grid>
                        </Grid>
                        <!--日历不可用的遮罩层-->
                        <Rectangle x:Name="PART_DisabledVisual"
                                        Fill="{StaticResource DisabledColor}"
                                        Opacity="0"
                                        RadiusY="2"
                                        RadiusX="2"
                                        Stretch="Fill"
                                        Stroke="{StaticResource DisabledColor}"
                                        StrokeThickness="1"
                                        Visibility="Collapsed" />
                    </Grid>
                    <!--触发器属性-->
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled"
                                      Value="False">
                            <Setter Property="Visibility"
                                         TargetName="PART_DisabledVisual"
                                         Value="Visible" />
                        </Trigger>
                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
                                          Value="Year">
                            <Setter Property="Visibility"
                                         TargetName="PART_MonthView"
                                         Value="Hidden" />
                            <Setter Property="Visibility"
                                         TargetName="PART_YearView"
                                         Value="Visible" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
                                          Value="Decade">
                            <Setter Property="Visibility"
                                         TargetName="PART_MonthView"
                                         Value="Hidden" />
                            <Setter Property="Visibility"
                                         TargetName="PART_YearView"
                                         Value="Visible" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type CalendarItem}" BasedOn="{StaticResource CalendarDefaultItemStyle}"/>


    
    <!--单个几号几号按钮的样式模版-->
    <Style x:Key="CalendarDayButtonStyleStyle" TargetType="{x:Type CalendarDayButton}">
        <Setter Property="Margin" Value="1" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="FontFamily" Value="微软雅黑" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                    <Border BorderBrush="#bbbbbb" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" Width="30" Height="30" Margin="5" CornerRadius="20">
                            <ContentPresenter x:Name="NormalText"
                                               TextElement.Foreground="{TemplateBinding Foreground}"
                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource BrandColor}"/>
                        </Trigger>
                        <Trigger Property="IsToday" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource BrandColor}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="White"/>
                            <Setter Property="Background" Value="{DynamicResource BrandColor}"/>
                        </Trigger>
                        <Trigger Property="IsInactive" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource PlaceholderTextColor}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="CalendarDayButton" BasedOn="{StaticResource CalendarDayButtonStyleStyle}"/>
    <Style x:Key="CalendarButtonStyle" TargetType="{x:Type CalendarButton}">
        <Setter Property="Background" Value="White" />
        <Setter Property="Margin" Value="10" />
        <Setter Property="FontSize" Value="16" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarButton}">
                    <Border CornerRadius="20" Background="{TemplateBinding Background}">
                        <ContentPresenter x:Name="NormalText"
                                               TextElement.Foreground="{TemplateBinding Foreground}"
                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                               Margin="1,0,1,1"
                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource BrandColor}"/>
                        </Trigger>
                        <Trigger Property="HasSelectedDays" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource BrandColor}"/>
                        </Trigger>
                        <Trigger Property="IsInactive" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource PlaceholderTextColor}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="CalendarDefaultStyle" TargetType="{x:Type Calendar}">
        <!--日历控件的背景色,也可以改成绑定的-->
        <Setter Property="Background" Value="White" />
        <Setter Property="Width" Value="350"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="CalendarItemStyle" Value="{StaticResource CalendarDefaultItemStyle}"/>
        <Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonStyle}"/>
        <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyleStyle}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Calendar}">
                    <StackPanel x:Name="PART_Root" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <!--这个是日历控件的主体元件,也是内部元件PART_CalendarItem名称不要更改,可以改它的其它样式属性-->
                        <CalendarItem x:Name="PART_CalendarItem"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           BorderThickness="{TemplateBinding BorderThickness}"
                                           Background="{TemplateBinding Background}"
                                           Style="{TemplateBinding CalendarItemStyle}"
                                           Height="{TemplateBinding Height}"
                                           Width="{TemplateBinding Width}" />
                    </StackPanel>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type Calendar}" BasedOn="{StaticResource CalendarDefaultStyle}"/>
</ResourceDictionary>