WPF 基础控件之 DatePicker 样式

此群已满340500857 ,请加新群458041663

       由于微信群人数太多入群请添加小编微信号

 yanjinhuawechatW_Feng_aiQ 邀请入群

 需备注WPF开发者 

 PS:有更好的方式欢迎推荐。

支持Nuget

Install-Package WPFDevelopers.Minimal -Version 3.2.0

01

代码如下

一、创建 Styles.DatePicker.xaml  代码如下。

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:sys="clr-namespace:System;assembly=mscorlib"xmlns:wpfs="clr-namespace:WPFDevelopers.Minimal.Helpers"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="../Themes/Basic/ControlBasic.xaml"/><ResourceDictionary Source="../Themes/Basic/Animations.xaml"/></ResourceDictionary.MergedDictionaries><Style TargetType="{x:Type CalendarDayButton}" x:Key="CalendarDayButtonStyle" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Width"  Value="32" /><Setter Property="Height" Value="32" /><Setter Property="FontSize"  Value="12" /><Setter Property="HorizontalContentAlignment" Value="Center" /><Setter Property="VerticalContentAlignment" Value="Center" /><Setter Property="Cursor" Value="Hand"/><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"/><VisualState Name="Pressed"/><VisualState Name="Disabled"/></VisualStateGroup><VisualStateGroup Name="SelectionStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="Unselected" /><VisualState Name="Selected"/></VisualStateGroup><VisualStateGroup Name="CalendarButtonFocusStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="CalendarButtonFocused"/><VisualState Name="CalendarButtonUnfocused"/></VisualStateGroup><VisualStateGroup Name="ActiveStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="Active" /><VisualState Name="Inactive"/></VisualStateGroup><VisualStateGroup Name="DayStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="RegularDay" /><VisualState Name="Today"/></VisualStateGroup><VisualStateGroup Name="BlackoutDayStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="NormalDay" /><VisualState Name="BlackoutDay"/></VisualStateGroup></VisualStateManager.VisualStateGroups><Ellipse x:Name="SelectedBackground" Opacity="0"><Ellipse.Fill><SolidColorBrush Color="{DynamicResource PrimaryMouseOverColor}" /></Ellipse.Fill></Ellipse><Border Background="{TemplateBinding Background}"BorderThickness="{TemplateBinding BorderThickness}"BorderBrush="{TemplateBinding BorderBrush}" /><Ellipse x:Name="DayButtonFocusVisual" Visibility="Collapsed"IsHitTestVisible="False"><Ellipse.Fill><SolidColorBrush Color="{DynamicResource PrimaryNormalColor}" /></Ellipse.Fill></Ellipse><ContentPresenter x:Name="NormalText"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"><TextElement.Foreground><SolidColorBrush Color="{DynamicResource RegularTextColor}" /></TextElement.Foreground></ContentPresenter><Path x:Name="Blackout" Opacity="0"  Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"Fill="#FF000000" Stretch="Fill"Data="{StaticResource PathBlackout}" /></Grid><ControlTemplate.Triggers><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsSelected" Value="False"/><Condition Property="IsMouseOver" Value="True"/></MultiTrigger.Conditions><Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource PrimaryMouseOverSolidColorBrush}"/></MultiTrigger><Trigger Property="IsToday" Value="True"><Setter TargetName="NormalText" Property="TextElement.FontWeight" Value="Bold"/><Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger><Trigger Property="IsSelected" Value="True"><Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource WhiteSolidColorBrush}"/><Setter TargetName="SelectedBackground" Property="Opacity" Value="1"/></Trigger><Trigger Property="IsInactive" Value="True"><Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource BaseSolidColorBrush}"/></Trigger><Trigger Property="IsBlackedOut" Value="True"><Setter TargetName="Blackout" Property="Opacity" Value=".2"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="{x:Type CalendarButton}" x:Key="CalendarButtonStyle" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="MinWidth" Value="48" /><Setter Property="MinHeight"  Value="32" /><Setter Property="FontSize" Value="12" /><Setter Property="HorizontalContentAlignment" Value="Center" /><Setter Property="VerticalContentAlignment" Value="Center" /><Setter Property="Cursor" Value="Hand"/><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><ColorAnimationUsingKeyFrames Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{DynamicResource PrimaryMouseOverColor}" ></EasingColorKeyFrame></ColorAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="Pressed"/></VisualStateGroup><VisualStateGroup Name="SelectionStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="Unselected" /><VisualState Name="Selected"><Storyboard><ColorAnimationUsingKeyFrames Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{DynamicResource PrimaryNormalColor}" ></EasingColorKeyFrame></ColorAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup><VisualStateGroup Name="ActiveStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="Active" /><VisualState Name="Inactive"/></VisualStateGroup><VisualStateGroup Name="CalendarButtonFocusStates"><VisualStateGroup.Transitions><VisualTransition GeneratedDuration="0" /></VisualStateGroup.Transitions><VisualState Name="CalendarButtonFocused"><Storyboard><ColorAnimationUsingKeyFrames Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{DynamicResource PrimaryNormalColor}" ></EasingColorKeyFrame></ColorAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="CalendarButtonUnfocused" /></VisualStateGroup></VisualStateManager.VisualStateGroups><ContentPresenter x:Name="NormalText"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"Margin="3,20"><TextElement.Foreground><SolidColorBrush Color="{DynamicResource RegularTextColor}" /></TextElement.Foreground></ContentPresenter></Grid><ControlTemplate.Triggers><Trigger Property="IsInactive" Value="True"><Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource BaseSolidColorBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><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"Storyboard.TargetName="PART_Path"Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"To="{DynamicResource PrimaryMouseOverColor}" /></Storyboard></VisualState><VisualState x:Name="Disabled"><Storyboard><DoubleAnimation Duration="0"To=".5"Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"Storyboard.TargetName="PART_Path" /></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups><Grid  Background="Transparent"><Path x:Name="PART_Path"Margin="14,-6,0,0"Stretch="Fill"HorizontalAlignment="Left"Height="10"VerticalAlignment="Center"Width="6"Data="{StaticResource PathPrevious}"><Path.Fill><SolidColorBrush Color="{DynamicResource RegularTextColor}" /></Path.Fill></Path></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="{StaticResource PrimaryMouseOverColor}"Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"Storyboard.TargetName="PART_Path" /></Storyboard></VisualState><VisualState x:Name="Disabled"><Storyboard><DoubleAnimation Duration="0"To=".5"Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"Storyboard.TargetName="PART_Path" /></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups><Grid Background="Transparent"><Path x:Name="PART_Path" Data="{StaticResource PathNext}" HorizontalAlignment="Right" Height="10" Margin="0,-6,14,0"Stretch="Fill" VerticalAlignment="Center" Width="6"><Path.Fill><SolidColorBrush Color="{DynamicResource RegularTextColor}" /></Path.Fill></Path></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"/><VisualState x:Name="Disabled"><Storyboard><DoubleAnimation Duration="0"To=".5"Storyboard.TargetProperty="Opacity"Storyboard.TargetName="PART_ButtonContent" /></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups><ContentPresenter x:Name="PART_ButtonContent"Margin="1,4,1,9"ContentTemplate="{TemplateBinding ContentTemplate}"Content="{TemplateBinding Content}"TextElement.Foreground="#FF333333"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /></Grid></ControlTemplate><Style x:Key="CalendarItemStyle" TargetType="{x:Type CalendarItem}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Margin"Value="24,4,24,24" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type CalendarItem}"><ControlTemplate.Resources><DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}"><StackPanel><TextBlock Foreground="{DynamicResource PrimaryTextSolidColorBrush}"FontSize="12"Margin="0,6"Text="{Binding}"HorizontalAlignment="Center"VerticalAlignment="Center" /><Rectangle Fill="{DynamicResource BaseSolidColorBrush}" Height="1"VerticalAlignment="Bottom"/></StackPanel></DataTemplate></ControlTemplate.Resources><Grid x:Name="PART_Root" Margin="{TemplateBinding Margin}"><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 Background="{DynamicResource WhiteSolidColorBrush}" BorderBrush="{DynamicResource BaseSolidColorBrush}"BorderThickness="1"CornerRadius="3" SnapsToDevicePixels="True" UseLayoutRounding="True"><Border.Effect><DropShadowEffect BlurRadius="12" Opacity="0.1" ShadowDepth="2" Color="Black" /></Border.Effect><Grid Margin="0,20,0,0"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*" /></Grid.RowDefinitions><Button x:Name="PART_PreviousButton"Template="{StaticResource PreviousButtonTemplate}"Focusable="False"HorizontalAlignment="Left"Grid.Column="0"Grid.Row="0"Height="20"Width="28" /><Button x:Name="PART_HeaderButton"Focusable="False"FontSize="14"HorizontalAlignment="Center"VerticalAlignment="Center"Grid.Column="1"Grid.Row="0"Template="{StaticResource HeaderButtonTemplate}" /><Button x:Name="PART_NextButton"Focusable="False"HorizontalAlignment="Right"Grid.Column="2"Grid.Row="0"Template="{StaticResource NextButtonTemplate}"Height="20"Width="28" /><Grid x:Name="PART_MonthView"Visibility="Visible"Grid.ColumnSpan="3"Grid.Row="1"Margin="6,10"VerticalAlignment="Center"HorizontalAlignment="Center"><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"Visibility="Hidden"Grid.ColumnSpan="3"Grid.Row="1"VerticalAlignment="Center"HorizontalAlignment="Center"Margin="6,-3,7,6"><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></Grid><ControlTemplate.Triggers><DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"Value="Year"><Setter Property="Visibility"TargetName="PART_MonthView"Value="Collapsed" /><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="Collapsed" /><Setter Property="Visibility"TargetName="PART_YearView"Value="Visible" /></DataTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="{x:Type Calendar}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="CalendarButtonStyle"Value="{StaticResource CalendarButtonStyle}" /><Setter Property="CalendarDayButtonStyle"Value="{StaticResource CalendarDayButtonStyle}" /><Setter Property="CalendarItemStyle"Value="{StaticResource CalendarItemStyle}" /><Setter Property="Foreground"Value="{DynamicResource PrimaryTextSolidColorBrush}" /><Setter Property="Background" Value="{DynamicResource WhiteSolidColorBrush}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Calendar}"><StackPanel x:Name="PART_Root"HorizontalAlignment="Center"><CalendarItem x:Name="PART_CalendarItem"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"Background="{TemplateBinding Background}"Style="{TemplateBinding CalendarItemStyle}" /></StackPanel></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="DatePickerCalendarStyle"TargetType="{x:Type Calendar}"BasedOn="{StaticResource {x:Type Calendar}}" /><Style x:Key="DropDownButtonStyle" TargetType="Button" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="30" /><ColumnDefinition /></Grid.ColumnDefinitions><Border x:Name="Border" Grid.ColumnSpan="2" BorderThickness="1" Background="{DynamicResource WhiteSolidColorBrush}" ></Border><Grid FlowDirection="LeftToRight"HorizontalAlignment="Center" Height="18"  VerticalAlignment="Center" Width="19"><Grid.ColumnDefinitions><ColumnDefinition Width="20*" /><ColumnDefinition Width="20*" /><ColumnDefinition Width="20*" /><ColumnDefinition Width="20*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="23*" /><RowDefinition Height="19*" /><RowDefinition Height="19*" /><RowDefinition Height="19*" /></Grid.RowDefinitions><Border x:Name="Highlight"BorderThickness="1"Grid.ColumnSpan="4"CornerRadius="0,0,1,1"Margin="-1"Opacity="1"Grid.Row="0"BorderBrush="{DynamicResource RegularTextSolidColorBrush}"Grid.RowSpan="4"></Border><Border x:Name="Background"BorderBrush="{DynamicResource RegularTextSolidColorBrush}"BorderThickness="1"Grid.ColumnSpan="4"CornerRadius=".5"Margin="0,-1,0,0"Opacity="1"Grid.Row="1"Grid.RowSpan="3"Background="{DynamicResource WhiteSolidColorBrush}"></Border><Border x:Name="BackgroundGradient"BorderBrush="{DynamicResource RegularTextSolidColorBrush}"BorderThickness="1"Grid.ColumnSpan="4"CornerRadius=".5"Margin="0,-1,0,0"Opacity="1"Grid.Row="1"Grid.RowSpan="3"Background="{DynamicResource WhiteSolidColorBrush}"></Border><Rectangle Grid.ColumnSpan="4" Grid.RowSpan="1" StrokeThickness="1"Fill="{DynamicResource RegularTextSolidColorBrush}"Stroke="{DynamicResource RegularTextSolidColorBrush}"></Rectangle><Path Fill="{DynamicResource RegularTextSolidColorBrush}" Grid.Row="1"Grid.Column="0"Grid.RowSpan="3"Grid.ColumnSpan="4"HorizontalAlignment="Center"VerticalAlignment="Center"RenderTransformOrigin="0.5,0.5"Margin="4,3,4,3"Stretch="Fill"Data="{StaticResource PathDatePickerDropDown}" /><Ellipse Grid.ColumnSpan="4"Fill="{DynamicResource WhiteSolidColorBrush}"HorizontalAlignment="Center"Height="3"StrokeThickness="0"VerticalAlignment="Center"Width="3" /><Border x:Name="DisabledVisual"BorderBrush="{DynamicResource WhiteSolidColorBrush}"BorderThickness="1"Grid.ColumnSpan="4"CornerRadius="0,0,.5,.5"Opacity="0"Grid.Row="0"Grid.RowSpan="4" /></Grid></Grid></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="{x:Type DatePickerTextBox}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" /><Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" /><Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/><!--<Setter Property="SelectionBrush" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/>--><Setter Property="Stylus.IsFlicksEnabled" Value="False"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="DatePickerTextBox"><Grid><Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"Padding="{TemplateBinding Padding}"CornerRadius="1" Opacity="1"><Grid x:Name="WatermarkContent"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"><Border x:Name="ContentElement" BorderThickness="1"><Border.BorderBrush><SolidColorBrush Color="{DynamicResource WhiteColor}"/></Border.BorderBrush></Border><ScrollViewer x:Name="PART_ContentHost" Margin="0"HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /><!--<Border x:Name="FocusVisual" BorderBrush="#FF45D6FA" CornerRadius="1" Opacity="0" IsHitTestVisible="False"/>--></Grid></Border></Grid></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="{x:Type DatePicker}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="IsTodayHighlighted"Value="True" /><Setter Property="SelectedDateFormat"Value="Short" /><Setter Property="Padding"Value="2" /><Setter Property="BorderThickness"Value="1" /><Setter Property="HorizontalContentAlignment"Value="Left" /><Setter Property="VerticalContentAlignment"Value="Center" /><Setter Property="MinWidth" Value="140"/><Setter Property="MinHeight" Value="{StaticResource MinHeight}" /><Setter Property="Cursor" Value="Hand"/><Setter Property="CalendarStyle"Value="{DynamicResource DatePickerCalendarStyle}" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type DatePicker}"><Border BorderThickness="{TemplateBinding BorderThickness}"Padding="{TemplateBinding Padding}" CornerRadius="{Binding Path=(wpfs:ElementHelper.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}"x:Name="PART_Border"BorderBrush="{StaticResource BaseSolidColorBrush}"Background="{StaticResource WhiteSolidColorBrush}"><Grid x:Name="PART_Root"HorizontalAlignment="Stretch"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"><Button x:Name="PART_Button"Foreground="{TemplateBinding Foreground}"Focusable="False"Margin="3,0,3,0"Style="{StaticResource DropDownButtonStyle}"VerticalAlignment="Top" /><DatePickerTextBox x:Name="PART_TextBox"Grid.Column="1"Foreground="{TemplateBinding Foreground}"Focusable="True"Width="Auto" HorizontalAlignment="Left"VerticalAlignment="Bottom"Margin="34,2,2,2"Background="Transparent" /><Popup x:Name="PART_Popup" MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"AllowsTransparency="True" Focusable="False" HorizontalOffset="-50"Placement="Bottom" StaysOpen="False" VerticalOffset="10"></Popup></Grid></Border><ControlTemplate.Triggers><Trigger Property="IsDropDownOpen" Value="True"><Setter Property="BorderBrush" TargetName="PART_Border" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>

二、使用 Styles.DatePicker.xaml  代码如下。

<WrapPanel Margin="0,10"><DatePicker Width="200"/><DatePicker Width="200" SelectedDateFormat="Long" Margin="10,0"/><DatePicker Width="200" IsEnabled="False"/></WrapPanel>

02


效果预览

鸣谢素材提供者element

源码地址如下

Github:https://github.com/WPFDevelopersOrg

Gitee:https://gitee.com/WPFDevelopersOrg

https://gitee.com/WPFDevelopersOrg/WPFDevelopers.Minimal

https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal

WPF开发者QQ群: 340500857 

Github:https://github.com/WPFDevelopersOrg

出处:https://www.cnblogs.com/yanjinhua

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

转载请著名作者 出处 https://github.com/WPFDevelopersOrg

c4419486290acae3d422e14acc7d4339.png

扫一扫关注我们,

c8192b56bc7f80f8c3249c5f7cee1b76.gif

更多知识早知道!

29c7d8d2842497a7cc04d66b8ba0ddef.gif

点击阅读原文可跳转至源代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/290389.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

stagefright框架(四)-Video Buffer传输流程

這篇文章將介紹Stagefright中是如何和OMX video decoder传送buffer。 (1) OMXCodec會在一開始的時候透過read函式來傳送未解碼的data給decoder&#xff0c;並且要求decoder將解碼後的data傳回來 status_t OMXCodec::read(...){ if (mInitialBufferSubmit) { mInitialBuffe…

微信支付四大支付模式分别有哪些区别?

微信支付是集成在微信客户端的支付功能&#xff0c;用户可以通过手机完成快速的支付流程。微信支付已为百货、餐厅、便利店、酒店、快递、景区、医院、售货机等提供了支付与营销的全方位支持。 目前微信支付已实现刷卡支付、扫码支付、公众号支付、APP支付&#xff0c;并提供企…

利用Deep Reinforcement Learning训练王者荣耀超强AI

Mastering Complex Control in MOBA Games with Deep Reinforcement Learning&#xff08;一&#xff09;知识背景&#xff08;二&#xff09;系统架构&#xff08;三&#xff09;算法结构3.1 Target Attention3.2 利用LSTM学习技能连招释放3.3 Decoupling of Control Dependen…

C和指针之编译出现warning: implicit declaration of function ‘matrix_multiply‘ is invalid in C99问题

1、问题 在我的mac上编译一个c文件&#xff0c;出现下面错误2、原因和解决办法 是因为我用vim的时候&#xff0c;把函数名少写了一个字符导致&#xff0c;把这个函数名改正就行了。

5. 堪比JMeter的.Net压测工具 - Crank 实战篇 - 接口以及场景压测

1. 前言通过之前的学习&#xff0c;我们已经掌握了crank的配置以及对应http基准工具bombardier、wrk、wrk2的用法&#xff0c;本篇文章介绍一下如何将其用于实战&#xff0c;在实际的项目中我们如何使用crank来完成压测任务。2. 项目背景目前有一个项目&#xff0c;我们希望通过…

Pytorch快速入门笔记

Pytorch 入门笔记1. Pytorch下载与安装2. Pytorch的使用教程2.1 Pytorch设计理念及其基本操作2.2 使用torch.nn搭建神经网络2.3 创建属于自己的Dataset和DataLoader2.3.1 编写Dataset类2.3.2 编写Transform类2.3.3 将Transform融合到Dataset中去2.3.4 编写DataLoader类2.4 使用…

详解用65行javascript代码做Flappy Bird

点击查看特效JavaScript做Flappy Bird游戏&#xff0c;代码仅仅65行资源包括&#xff1a;javascript源码&#xff1a;phaser.min.js&#xff1b;main.js&#xff1b;index.html素材&#xff1a;两张图片&#xff01;素材PS&#xff1a;素材源码下载来我的前端群570946165&#…

C和指针之数组编程练习5 (矩阵相乘)

1、问题 5.如果A是个x行y列的矩阵,B是个y行z列的矩阵,把A和B相乘,其结果将是另一个x行z列的矩阵C。这个矩阵的每个元素是由下面的公式决定的: 例如: 结果矩阵中14这个值是通过2-2加上-6-3得到的,编写一个函数,用于执行两个矩阵的乘法。函数的原型如下: void matrix_mul…

我的技术回顾因ABP框架触发DevOps云原生之路-2020年

我的技术回顾&#xff1a;2015年&#xff1a;我的技术回顾那些与ABP框架有关的故事-2015年2016年&#xff1a;从ABP框架国内社区发展回顾.NET技术变迁-2016年2017年&#xff1a;我的技术回顾那些与ABP框架有关的故事-2017年2018年&#xff1a;我的技术回顾那些与ABP框架有关的故…

半身头像

画的好丑。。。继续加油 转载于:https://www.cnblogs.com/manlurensheng/p/4102631.html

Swift - 操作SQLite数据库(引用SQLite3库)

SQLite轻量级数据库在移动应用中使用非常普遍&#xff0c;但是目前的库是C编写的&#xff0c;为了方便使用&#xff0c;对SQLite相关的操作用Swift进行了封装。这个封装代码使用了一个开源项目SQLiteDB&#xff0c;地址是&#xff1a;https://github.com/fahimf/sqlitedb 重要事…

如何在Clion中使用C++调用Python代码

在很多时候&#xff0c;我们需要在一个c工程项目中调用部分Python代码&#xff0c;这就需要我们实现Python和C之间的交互。交互方式有两种&#xff1a;1. 依靠 TCP 建立的网络通信交互&#xff1b;2. 嵌入式混合语言编程&#xff08;Embedding Code&#xff09;。这里主要介绍后…

.NET6之MiniAPI(二十四):用Polly重试

为了保障系统的稳定和安全&#xff0c;在调用三方服务时&#xff0c;可以增加重试和熔断。重试是调用一次失败后再试几试&#xff0c;避免下游服务一次闪断&#xff0c;就把整个链路终止&#xff1b;熔断是为了防止太多的次数的无效访问&#xff0c;导致系统不可知异常。Polly是…

CLion 中使用 C++ 版本的 OpenCV

配置环境&#xff1a; Windows 10CLion 2020OpenCV 3.4.1MinGW-w64 1. 下载 CLion 并配置好 MinGW CLion 下载地址&#xff1a;https://www.jetbrains.com/clion MinGW 安装包下载地址&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1c00uHbcf_jGeDDrVg99jtA 提取码&…

如何理解 C# 中的 System.Void 类型?

咨询区 ordag我知道方法声明成 void 表示不返回什么东西&#xff0c;但我发现在 C# 中 void 不仅仅是一个关键词&#xff0c;而且还是一个真实的类型。void 是 System.Void 的别名&#xff0c;就像 int 的别名是 System.Int32 一样&#xff0c;但为什么不允许直接使用Void类型呢…

获得手机的ip

本文转载至 http://blog.csdn.net/showhilllee/article/details/8746114 iosip手机貌似ASI里获取ip地址的链接不可以了。也曾试过whatismyip&#xff0c;在其网站上的截图获取的ip是正确的&#xff0c;单不知道为什么在我这里却是错误的。所以&#xff0c;在这里分享一下获得手…

Idea maven项目不能新建package和class的解决

如图&#xff0c;新建的maven项目不能新建package 这是因为Java是普通的文件夹&#xff0c;要设置为 现在就可以了

基于文本知识库的强化学习技术——Learning to Win by Reading Manuals in a Monte-Carlo Framework

论文链接&#xff1a;http://people.csail.mit.edu/branavan/papers/acl2011.pdf 文章目录1. 背景介绍2. 将攻略文本引入值函数 Q(s,a)Q(s, a)Q(s,a) 评价2.1 复杂环境下使用传统 Q(s,a)Q(s, a)Q(s,a) 函数的缺陷2.2 设计 Q(s,a,d)Q(s, a, d)Q(s,a,d) 神经网络2.3 模型训练流程…

这是Blazor上传文件的最佳方式吗?

Blazor不得不说真是好东西&#xff0c;极大的提升了开发效率&#xff0c;很多的页面交互功能基本上只需要写很少的代码就能实现了&#xff0c;而且还是无js实现&#xff0c;你也绝对没有想到过&#xff0c;Blazor实现文件上传是有多么简单&#xff01;先说结论&#xff1a;Blaz…

ubuntu 下安装五笔输入法

2019独角兽企业重金招聘Python工程师标准>>> 从两年开始用五笔的吧&#xff0c;自从我学会用五笔之后&#xff0c;基本上就没有用过拼音了&#xff0c;我记忆中使用拼音也就那么几次&#xff0c;好像都是在远程协助别人的时候&#xff0c;用他们电脑上的拼音。然后我…