ControlTemplate in WPF —— DatePicker
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <!--In this example, an implecit style for Calendar is defined elsewhere
- in the application. DatePickerCalendarStyle is based on the implicit
- style so that the DatePicker will use the application's calendar style.-->
- <Style x:Key="DatePickerCalendarStyle"
- TargetType="{x:Type Calendar}"
- BasedOn="{StaticResource {x:Type Calendar}}" />
- <!--The template for the button that displays the calendar.-->
- <Style x:Key="DropDownButtonStyle"
- TargetType="Button">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualStateGroup.Transitions>
- <VisualTransition GeneratedDuration="" />
- <VisualTransition GeneratedDuration="0:0:0.1"
- To="MouseOver" />
- <VisualTransition GeneratedDuration="0:0:0.1"
- To="Pressed" />
- </VisualStateGroup.Transitions>
- <VisualState x:Name="Normal" />
- <VisualState x:Name="MouseOver">
- <Storyboard>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#F2FFFFFF" />
- </ColorAnimationUsingKeyFrames>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#CCFFFFFF" />
- </ColorAnimationUsingKeyFrames>
- <ColorAnimation Duration=""
- To="#FF448DCA"
- Storyboard.TargetProperty="(Border.Background).
- (SolidColorBrush.Color)"
- Storyboard.TargetName="Background" />
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#7FFFFFFF" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Pressed">
- <Storyboard>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="Background"
- Storyboard.TargetProperty="(Border.Background).
- (SolidColorBrush.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#FF448DCA" />
- </ColorAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetProperty="(UIElement.Opacity)"
- Storyboard.TargetName="Highlight">
- <SplineDoubleKeyFrame KeyTime=""
- Value="" />
- </DoubleAnimationUsingKeyFrames>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#F4FFFFFF" />
- </ColorAnimationUsingKeyFrames>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#EAFFFFFF" />
- </ColorAnimationUsingKeyFrames>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#C6FFFFFF" />
- </ColorAnimationUsingKeyFrames>
- <ColorAnimationUsingKeyFrames BeginTime=""
- Duration="00:00:00.001"
- Storyboard.TargetName="BackgroundGradient"
- Storyboard.TargetProperty="(Border.Background).
- (GradientBrush.GradientStops)[].(GradientStop.Color)">
- <SplineColorKeyFrame KeyTime=""
- Value="#6BFFFFFF" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Disabled" />
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <Grid Background="#11FFFFFF"
- FlowDirection="LeftToRight"
- HorizontalAlignment="Center"
- Height=""
- Margin=""
- VerticalAlignment="Center"
- Width="">
- <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=""
- Grid.ColumnSpan=""
- CornerRadius="0,0,1,1"
- Margin="-1"
- Opacity=""
- Grid.Row=""
- Grid.RowSpan="">
- <Border.BorderBrush>
- <SolidColorBrush Color="{DynamicResource ControlPressedColor}" />
- </Border.BorderBrush>
- </Border>
- <Border x:Name="Background"
- BorderBrush="#FFFFFFFF"
- BorderThickness=""
- Grid.ColumnSpan=""
- CornerRadius=".5"
- Margin="0,-1,0,0"
- Opacity=""
- Grid.Row=""
- Grid.RowSpan="">
- <Border.Background>
- <SolidColorBrush Color="{DynamicResource ControlDarkColor}" />
- </Border.Background>
- </Border>
- <Border x:Name="BackgroundGradient"
- BorderBrush="#BF000000"
- BorderThickness=""
- Grid.ColumnSpan=""
- CornerRadius=".5"
- Margin="0,-1,0,0"
- Opacity=""
- Grid.Row=""
- Grid.RowSpan="">
- <Border.Background>
- <LinearGradientBrush EndPoint=".7,1"
- StartPoint=".7,0">
- <GradientStop Color="#FFFFFFFF"
- Offset="" />
- <GradientStop Color="#F9FFFFFF"
- Offset="0.375" />
- <GradientStop Color="#E5FFFFFF"
- Offset="0.625" />
- <GradientStop Color="#C6FFFFFF"
- Offset="" />
- </LinearGradientBrush>
- </Border.Background>
- </Border>
- <Rectangle Grid.ColumnSpan=""
- Grid.RowSpan=""
- StrokeThickness="">
- <Rectangle.Fill>
- <LinearGradientBrush EndPoint="0,1"
- StartPoint="0,0">
- <GradientStop Color="{DynamicResource HeaderTopColor}" />
- <GradientStop Color="{DynamicResource ControlMediumColor}"
- Offset="" />
- </LinearGradientBrush>
- </Rectangle.Fill>
- <Rectangle.Stroke>
- <LinearGradientBrush EndPoint="0.48,-1"
- StartPoint="0.48,1.25">
- <GradientStop Color="#FF494949" />
- <GradientStop Color="#FF9F9F9F"
- Offset="" />
- </LinearGradientBrush>
- </Rectangle.Stroke>
- </Rectangle>
- <Path Fill="#FF2F2F2F"
- Grid.Row=""
- Grid.Column=""
- Grid.RowSpan=""
- Grid.ColumnSpan=""
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- RenderTransformOrigin="0.5,0.5"
- Margin="4,3,4,3"
- Stretch="Fill"
- Data="M11.426758,8.4305077 L11.749023,8.4305077
- L11.,16.331387 L10.,16.331387
- L10.,10.299648 L9.,11.298672
- L9.,10.294277 C9.,10.090176
- 9.9094238,9.8090878 10.365967,9.4510155
- C10.,9.0929432 11.176106,8.7527733
- 11.426758,8.4305077 z M14.,8.4305077
- L18.,8.4305077 L18.,9.3435936
- L15.,9.3435936 L15.,11.255703
- C15.,11.058764 16.27293,10.960293
- 16.681133,10.960293 C17.,10.960293
- 17.969301,11.178717 18.354229,11.615566
- C18.,12.052416 18.931622,12.673672
- 18.931622,13.479336 C18.,15.452317
- 18.052553,16.438808 16.294415,16.438808
- C15.,16.438808 14.951641,16.234707
- 14.468243,15.826504 L14.,14.929531
- C15.,15.326992 15.837872,15.525723
- 16.289043,15.525723 C17.,15.525723
- 17.803692,14.895514 17.803692,13.635098
- C17.,12.460618 17.305971,11.873379
- 16.310528,11.873379 C15.,11.873379
- 15.399232,12.079271 15.016094,12.491055
- L14.,12.238613 z" />
- <Ellipse Grid.ColumnSpan=""
- Fill="#FFFFFFFF"
- HorizontalAlignment="Center"
- Height=""
- StrokeThickness=""
- VerticalAlignment="Center"
- Width="" />
- <Border x:Name="DisabledVisual"
- BorderBrush="#B2FFFFFF"
- BorderThickness=""
- Grid.ColumnSpan=""
- CornerRadius="0,0,.5,.5"
- Opacity=""
- Grid.Row=""
- Grid.RowSpan="" />
- </Grid>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style TargetType="{x:Type DatePicker}">
- <Setter Property="Foreground"
- Value="#FF333333" />
- <Setter Property="IsTodayHighlighted"
- Value="True" />
- <Setter Property="SelectedDateFormat"
- Value="Short" />
- <Setter Property="Padding"
- Value="" />
- <Setter Property="BorderThickness"
- Value="" />
- <Setter Property="HorizontalContentAlignment"
- Value="Stretch" />
- <!--Set CalendarStyle to DatePickerCalendarStyle.-->
- <Setter Property="CalendarStyle"
- Value="{DynamicResource DatePickerCalendarStyle}" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type DatePicker}">
- <Border BorderThickness="{TemplateBinding BorderThickness}"
- Padding="{TemplateBinding Padding}">
- <Border.BorderBrush>
- <LinearGradientBrush EndPoint="0.5,1"
- StartPoint="0.5,0">
- <GradientStop Color="{DynamicResource BorderLightColor}"
- Offset="" />
- <GradientStop Color="{DynamicResource BorderDarkColor}"
- Offset="" />
- </LinearGradientBrush>
- </Border.BorderBrush>
- <Border.Background>
- <LinearGradientBrush EndPoint="0.5,1"
- StartPoint="0.5,0">
- <GradientStop Color="{DynamicResource HeaderTopColor}"
- Offset="" />
- <GradientStop Color="{DynamicResource ControlMediumColor}"
- Offset="" />
- </LinearGradientBrush>
- </Border.Background>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="Disabled">
- <Storyboard>
- <DoubleAnimation Duration=""
- To=""
- Storyboard.TargetProperty="Opacity"
- Storyboard.TargetName="PART_DisabledVisual" />
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <Grid x:Name="PART_Root"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <Button x:Name="PART_Button"
- Grid.Column=""
- Foreground="{TemplateBinding Foreground}"
- Focusable="False"
- HorizontalAlignment="Left"
- Margin="3,0,3,0"
- Grid.Row=""
- Style="{StaticResource DropDownButtonStyle}"
- VerticalAlignment="Top" />
- <DatePickerTextBox x:Name="PART_TextBox"
- Grid.Column=""
- Foreground="{TemplateBinding Foreground}"
- Focusable="{TemplateBinding Focusable}"
- HorizontalContentAlignment="Stretch"
- Grid.Row=""
- VerticalContentAlignment="Stretch" />
- <Grid x:Name="PART_DisabledVisual"
- Grid.ColumnSpan=""
- Grid.Column=""
- IsHitTestVisible="False"
- Opacity=""
- Grid.Row="">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <Rectangle Grid.Column=""
- Fill="#A5FFFFFF"
- RadiusY=""
- Grid.Row=""
- RadiusX="" />
- <Rectangle Grid.Column=""
- Fill="#A5FFFFFF"
- Height=""
- Margin="3,0,3,0"
- RadiusY=""
- Grid.Row=""
- RadiusX=""
- Width="" />
- <Popup x:Name="PART_Popup"
- AllowsTransparency="True"
- Placement="Bottom"
- PlacementTarget="{Binding ElementName=PART_TextBox}"
- StaysOpen="False" />
- </Grid>
- </Grid>
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ResourceDictionary>
ControlTemplate in WPF —— DatePicker的更多相关文章
- WPF DatePicker默认显示当前日期,格式化为年月日
原文:WPF DatePicker默认显示当前日期 WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里 ...
- WPF DatePicker默认显示当前日期
WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里,具体请看下面. 1.方法一: my ...
- wpf datepicker 样式
在项目中用到的 <Style TargetType="{x:Type DatePicker}"> <Setter Property="Foregroun ...
- WPF DatePicker只显示年和月 修改:可以只显示年
最近的项目,查询时只需要年和月,不需要日,因此需要对原有的DatePicker进行修改,查询了网上的内容,最终从一篇帖子里看到了添加附加属性的方法,地址是http://stackoverflow.co ...
- Wpf DatePicker 水印修改为中文
效果图: 在App.cs添加如下代码: protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Event ...
- WPF: DatePicker
获取DatePicker:date_Start上显示的时间date_Start.SelectedDate 比较两个dateTime类型的时间: DateTime StartDate =Convert. ...
- WPF DatePicker 添加水印效果
这个控件没有水印属性,依然使用依赖属性解决 public class DatePickerHelper { public static object GetWatermark(DependencyOb ...
- WPF DatePicker 默认显示当前时间
两种方法: 1.通过后台赋值: this.datePicker.SelectedDate = DateTime.Now; 2.前台控件的属性直接赋值 xmlns:sys="clr-names ...
- WPF DatePicker日期控件只显示年月
1.需要引用2个类,第一个类DatePickerCalendar public class DatePickerCalendar { public static readonly Dependency ...
随机推荐
- 31、NTP时间服务器
1.NTP简介 NTP服务器顾名思义就是时间同步服务器(Network Time Protocol),Linux下的ntp服务器配置相对来说都比较容易,但在Linux下有一个弊端,不同时区或者说是时间 ...
- CentOS7 配置NFS(Network File System)及其使用
1. 服务端配置 1.1. 安装NFS yum -y install nfs* 1.2. 查看是否安装了NFS与RPCBIND rpm -qa | grep nfs rpm - ...
- 新建swap分区
1.在一块新盘上创建一个主分区,大小为1G大小. 2.将该硬盘数据变更为82(swap),并进行保存 3.查看是否已经将新建分区更改成了swap分区 4.将/dev/sdb2的标签设置为swap-sd ...
- 使用Vue自定义组件时,报did you register the component correctly? For recursive components, make sure to provide the "name" option.(未注册组件)的原因之一
错误信息: [Vue warn]: Unknown custom element: <list> - did you register the component correctly? F ...
- 微信小程序let和var以及const有什么区别
在JavaScript中有三种声明变量的方式:var.let.const. var:声明全局变量,换句话理解就是,声明在for循环中的变量,跳出for循环同样可以使用. for(var i=0;i&l ...
- CSS3 选择器——笔记+实战案例(基本选择器、组合选择器、属性选择器、伪类选择器)
使用CSS3 选择器——笔记 CSS通过选择器控制HTML元素,CSS选择器对网页对象可以实现一对一.一对多或者多对一的匹配. 一.CSS3选择器分类 CSS选择器在CSS2.1选择器的基础上新增了属 ...
- Python 操作 MySQL 数据库Ⅳ
执行事务 事务机制可以确保数据一致性. 事务应该具有4个属性:原子性.一致性.隔离性.持久性.这四个属性通常称为ACID特性. 原子性(atomicity).一个事务是一个不可分割的工作单位,事务中包 ...
- Python 异常处理Ⅱ
异常处理 捕捉异常可以使用try/except语句. try/except语句用来检测try语句块中的错误,从而让except语句捕获异常信息并处理. 如果你不想在异常发生时结束你的程序,只需在try ...
- Java架构师面试题——JVM性能调优
JVM内存调优 对JVM内存的系统级的调优主要的目的是减少GC的频率和Full GC的次数. 1.Full GC 会对整个堆进行整理,包括Young.Tenured和Perm.Full GC因为需要对 ...
- count(列) count(*)
总结:但是真的结论是这样的么.其实不然.其实在数据库中count(*)和count(列)根本就是不等价的,count(*)是针对于全表的,而count(列)是针对于某一列的,如果此列值为空的话,cou ...