分享一个WPF下日历控件(Calendar)的样式

简介: 原文:分享一个WPF下日历控件(Calendar)的样式WPF日历控件的一个样式 WPF自带的日历控件样式可能会比较丑,要修改其样式看起来挺复杂的,实际上很简单,用Blend打开,修改三个模板,基本就能改变全部面貌,也很容易 先上图 样式如下: ...
原文: 分享一个WPF下日历控件(Calendar)的样式

WPF日历控件的一个样式

WPF自带的日历控件样式可能会比较丑,要修改其样式看起来挺复杂的,实际上很简单,用Blend打开,修改三个模板,基本就能改变全部面貌,也很容易

先上图
xxx
xxx
xxx

样式如下:

<Style TargetType="TextBlock"
           x:Key="AwesomeTextStyle">
        <Setter Property="FontFamily"
                Value="pack://application:,,,/Resources/#FontAwesome"></Setter>
    </Style>

    <Style x:Key="CalendarItemStyle1"
           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 Foreground="#FF333333"
                                       FontWeight="Bold"
                                       FontSize="9.5"
                                       FontFamily="Verdana"
                                       HorizontalAlignment="Center"
                                       Margin="0,6,0,6"
                                       Text="{Binding}"
                                       VerticalAlignment="Center" />
                        </DataTemplate>
                    </ControlTemplate.Resources>
                    <Grid x:Name="PART_Root"
                          Margin="5">
                        <Grid.Effect>
                            <DropShadowEffect BlurRadius="10"
                                              ShadowDepth="3"
                                              Direction="270"
                                              Color="#1685f1"
                                              Opacity=".42"
                                              RenderingBias="Performance"></DropShadowEffect>
                        </Grid.Effect>
                        <Grid.Resources>
                            <SolidColorBrush x:Key="DisabledColor"
                                             Color="#A5FFFFFF" />
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To="1"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="PART_DisabledVisual" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border BorderBrush="Transparent"
                                BorderThickness="0"
                                Background="White">
                            <Border BorderBrush="#FFFFFFFF">
                                <Grid>
                                    <Grid.Resources>
                                        <ControlTemplate x:Key="PreviousButtonTemplate"
                                                         TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">

                                                <Border x:Name="Border"
                                                        Background="White"
                                                        Opacity="0"></Border>

                                                <Ellipse x:Name="Ellipse"
                                                         Width="15"
                                                         Height="15"
                                                         Fill="White"></Ellipse>
                                                <TextBlock Foreground="#1685f1"
                                                           FontSize="14"
                                                           Margin="0,0,2,1"
                                                           VerticalAlignment="Center"
                                                           HorizontalAlignment="Center"
                                                           Style="{StaticResource AwesomeTextStyle}"
                                                           Text="&#xf104;"></TextBlock>

                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0.3"></Setter>
                                                </Trigger>
                                                <Trigger Property="IsPressed"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0"></Setter>
                                                </Trigger>

                                                <Trigger Property="IsEnabled"
                                                         Value="False">
                                                    <Setter TargetName="Ellipse"
                                                            Property="Fill"
                                                            Value="Gray"></Setter>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                        <ControlTemplate x:Key="NextButtonTemplate"
                                                         TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">

                                                <Border x:Name="Border"
                                                        Background="White"
                                                        Opacity="0"></Border>

                                                <Ellipse x:Name="Ellipse"
                                                         Width="15"
                                                         Height="15"
                                                         Fill="White"></Ellipse>
                                                <TextBlock Foreground="#1685f1"
                                                           FontSize="14"
                                                           Margin="2,0,0,1"
                                                           VerticalAlignment="Center"
                                                           HorizontalAlignment="Center"
                                                           Style="{StaticResource AwesomeTextStyle}"
                                                           Text="&#xf105;"></TextBlock>

                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0.3"></Setter>
                                                </Trigger>
                                                <Trigger Property="IsPressed"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0"></Setter>
                                                </Trigger>

                                                <Trigger Property="IsEnabled"
                                                         Value="False">
                                                    <Setter TargetName="Ellipse"
                                                            Property="Fill"
                                                            Value="Gray"></Setter>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                        <ControlTemplate x:Key="HeaderButtonTemplate"
                                                         TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">
                                                <Border x:Name="Border"
                                                        Background="White"
                                                        Opacity="0"></Border>
                                                <ContentPresenter x:Name="buttonContent"
                                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                  Content="{TemplateBinding Content}"
                                                                  TextElement.Foreground="White"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0.3"></Setter>
                                                </Trigger>
                                                <Trigger Property="IsPressed"
                                                         Value="True">
                                                    <Setter TargetName="Border"
                                                            Property="Opacity"
                                                            Value="0"></Setter>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Grid.Resources>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="40" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>



                                    <Rectangle></Rectangle>

                                    <Border Grid.Row="0"
                                            Grid.Column="0"
                                            Grid.ColumnSpan="3"
                                            Background="#1685f1"></Border>

                                    <Button x:Name="PART_PreviousButton"
                                            Grid.Column="0"
                                            Focusable="False"
                                            Grid.Row="0"
                                            Template="{StaticResource PreviousButtonTemplate}" />
                                    <Button x:Name="PART_HeaderButton"
                                            Grid.Column="1"
                                            Focusable="False"
                                            FontSize="15"
                                            Grid.Row="0"
                                            Template="{StaticResource HeaderButtonTemplate}" />
                                    <Button x:Name="PART_NextButton"
                                            Grid.Column="2"
                                            Focusable="False"
                                            Grid.Row="0"
                                            Template="{StaticResource NextButtonTemplate}" />
                                    <Grid x:Name="PART_MonthView"
                                          Grid.ColumnSpan="3"
                                          HorizontalAlignment="Center"
                                          Margin="6,-1,6,6"
                                          Grid.Row="1"
                                          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 x:Name="PART_YearView"
                                          Grid.ColumnSpan="3"
                                          HorizontalAlignment="Center"
                                          Margin="6,-3,7,6"
                                          Grid.Row="1"
                                          Visibility="Hidden">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition />
                                            <ColumnDefinition />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                        </Grid.RowDefinitions>
                                    </Grid>

                                    <Grid x:Name="DayBorder"
                                          Grid.Row="1"
                                          Grid.ColumnSpan="3">
                                        <Rectangle Fill="#447bb3"
                                                   VerticalAlignment="Top"
                                                   Height="0.5"
                                                   Margin="2,19,2,0"></Rectangle>
                                    </Grid>
                                </Grid>
                            </Border>
                        </Border>
                        <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 TargetName="DayBorder"
                                    Property="Visibility"
                                    Value="Collapsed"></Setter>
                            <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 TargetName="DayBorder"
                                    Property="Visibility"
                                    Value="Collapsed"></Setter>
                            <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 x:Key="CalendarDayButtonStyle1"
           TargetType="{x:Type CalendarDayButton}">
        <Setter Property="MinWidth"
                Value="5" />
        <Setter Property="MinHeight"
                Value="5" />
        <Setter Property="FontSize"
                Value="15" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                    <Grid Width="30"
                          Height="30">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To="0.5"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="HighlightBackground" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To="0.5"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="HighlightBackground" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To="0"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="HighlightBackground" />
                                        <DoubleAnimation Duration="0"
                                                         To=".35"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="NormalText" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected" />
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To=".75"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="SelectedBackground" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="CalendarButtonFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="DayButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CalendarButtonUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="DayButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ActiveStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Active" />
                                <VisualState x:Name="Inactive">
                                    <Storyboard>
                                        <ColorAnimation Duration="0"
                                                        To="#FF777777"
                                                        Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                        Storyboard.TargetName="NormalText" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="DayStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="RegularDay" />
                                <VisualState x:Name="Today">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To="1"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="TodayBackground" />
                                        <ColorAnimation Duration="0"
                                                        To="#FFFFFFFF"
                                                        Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                        Storyboard.TargetName="NormalText" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="BlackoutDayStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="NormalDay" />
                                <VisualState x:Name="BlackoutDay">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To=".2"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="Blackout" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Ellipse x:Name="TodayBackground"
                                 Fill="#1a7ee0"
                                 Opacity="0" />
                        <Ellipse x:Name="SelectedBackground"
                                 Fill="#1a7ee0"
                                 Opacity="0" />
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" />
                        <Ellipse x:Name="HighlightBackground"
                                 Fill="#FFBADDE9"
                                 Opacity="0" />
                        <ContentPresenter x:Name="NormalText"
                                          TextElement.Foreground="#FF333333"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="5,1,5,1"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        <Path x:Name="Blackout"
                              Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z"
                              Fill="#FF000000"
                              HorizontalAlignment="Stretch"
                              Margin="3"
                              Opacity="0"
                              RenderTransformOrigin="0.5,0.5"
                              Stretch="Fill"
                              VerticalAlignment="Stretch" />
                        <Rectangle x:Name="DayButtonFocusVisual"
                                   IsHitTestVisible="false"
                                   RadiusY="1"
                                   RadiusX="1"
                                   Stroke="Transparent"
                                   Visibility="Visible" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="CalendarButtonStyle1"
           TargetType="{x:Type CalendarButton}">
        <Setter Property="Background"
                Value="#1685f1" />
        <Setter Property="FontSize"
                Value="12" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarButton}">
                    <Grid Width="55">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To=".5"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="Background" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To=".5"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="Background" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected" />
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         To=".75"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="SelectedBackground" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ActiveStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Active" />
                                <VisualState x:Name="Inactive">
                                    <Storyboard>
                                        <ColorAnimation Duration="0"
                                                        To="#FF777777"
                                                        Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
                                                        Storyboard.TargetName="NormalText" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="CalendarButtonFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="CalendarButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CalendarButtonUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="CalendarButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="SelectedBackground"
                                   Fill="{TemplateBinding Background}"
                                   Opacity="0"
                                   RadiusY="1"
                                   RadiusX="1" />
                        <Rectangle x:Name="Background"
                                   Fill="{TemplateBinding Background}"
                                   Opacity="0"
                                   RadiusY="1"
                                   RadiusX="1" />
                        <ContentPresenter x:Name="NormalText"
                                          TextElement.Foreground="#FF333333"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        <Rectangle x:Name="CalendarButtonFocusVisual"
                                   IsHitTestVisible="false"
                                   RadiusY="1"
                                   RadiusX="1"
                                   Stroke="Transparent"
                                   Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter Property="Visibility"
                                    TargetName="CalendarButtonFocusVisual"
                                    Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Calendar">
        <Setter Property="CalendarDayButtonStyle"
                Value="{StaticResource CalendarDayButtonStyle1}"></Setter>
        <Setter Property="CalendarItemStyle"
                Value="{StaticResource CalendarItemStyle1}"></Setter>
        <Setter Property="CalendarButtonStyle"
                Value="{StaticResource CalendarButtonStyle1}"></Setter>
    </Style>

其中某些图形可能来自于 FontAwesome.otf,大家百度下,添加到项目中即可

目录
相关文章
|
3月前
|
C# 开发者 Windows
一款基于Fluent设计风格、现代化的WPF UI控件库
一款基于Fluent设计风格、现代化的WPF UI控件库
|
3月前
|
C# Windows
WPF中如何使用HandyCotrol控件库
WPF中如何使用HandyCotrol控件库
195 1
|
3月前
|
开发者 C# 存储
WPF开发者必读:资源字典应用秘籍,轻松实现样式与模板共享,让你的WPF应用更上一层楼!
【8月更文挑战第31天】在WPF开发中,资源字典是一种强大的工具,用于共享样式、模板、图像等资源,提高了应用的可维护性和可扩展性。本文介绍了资源字典的基础知识、创建方法及最佳实践,并通过示例展示了如何在项目中有效利用资源字典,实现资源的重用和动态绑定。
93 0
|
3月前
|
C# 前端开发 UED
WPF数据验证实战:内置控件与自定义规则,带你玩转前端数据验证,让你的应用程序更上一层楼!
【8月更文挑战第31天】在WPF应用开发中,数据验证是确保输入正确性的关键环节。前端验证能及时发现错误,提升用户体验和程序可靠性。本文对比了几种常用的WPF数据验证方法,并通过示例展示了如何使用内置验证控件(如`TextBox`)及自定义验证规则实现有效验证。内置控件结合`Validation`类可快速实现简单验证;自定义规则则提供了更灵活的复杂逻辑支持。希望本文能帮助开发者更好地进行WPF数据验证。
116 0
|
3月前
|
开发者 C# 存储
WPF开发者必读:样式与模板的艺术,轻松定制UI外观,让你的应用程序更上一层楼!
【8月更文挑战第31天】在WPF应用开发中,样式与模板是实现美观界面与一致性的关键工具。样式定义了控件如字体、颜色等属性,而模板则允许自定义控件布局与子控件,两者均可存储于`.xaml`文件中。本文介绍了样式与模板的基础知识,通过示例展示了如何创建并应用它们来改变按钮的外观,从而提升用户体验。
90 0
|
3月前
|
C# UED 定位技术
WPF控件大全:初学者必读,掌握控件使用技巧,让你的应用程序更上一层楼!
【8月更文挑战第31天】在WPF应用程序开发中,控件是实现用户界面交互的关键元素。WPF提供了丰富的控件库,包括基础控件(如`Button`、`TextBox`)、布局控件(如`StackPanel`、`Grid`)、数据绑定控件(如`ListBox`、`DataGrid`)等。本文将介绍这些控件的基本分类及使用技巧,并通过示例代码展示如何在项目中应用。合理选择控件并利用布局控件和数据绑定功能,可以提升用户体验和程序性能。
69 0
|
3月前
|
存储 前端开发 C#
WPF/C#:更改界面的样式
WPF/C#:更改界面的样式
44 0
|
3月前
|
前端开发 C#
wpfui:一个开源免费具有现代化设计趋势的WPF控件库
wpfui:一个开源免费具有现代化设计趋势的WPF控件库
139 0
|
6月前
|
C# 开发者 Windows
基于Material Design风格开源、易用、强大的WPF UI控件库
基于Material Design风格开源、易用、强大的WPF UI控件库
389 0
|
6月前
|
C#
浅谈WPF之装饰器实现控件锚点
使用过visio的都知道,在绘制流程图时,当选择或鼠标移动到控件时,都会在控件的四周出现锚点,以便于修改大小,移动位置,或连接线等,那此功能是如何实现的呢?在WPF开发中,想要在控件四周实现锚点,可以通过装饰器来实现,今天通过一个简单的小例子,简述如何在WPF开发中,应用装饰器,仅供学习分享使用,如有不足之处,还请指正。
142 1