1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3.  
  4. <!--In this example, an implecit style for Calendar is defined elsewhere
  5. in the application. DatePickerCalendarStyle is based on the implicit
  6. style so that the DatePicker will use the application's calendar style.-->
  7. <Style x:Key="DatePickerCalendarStyle"
  8. TargetType="{x:Type Calendar}"
  9. BasedOn="{StaticResource {x:Type Calendar}}" />
  10.  
  11. <!--The template for the button that displays the calendar.-->
  12. <Style x:Key="DropDownButtonStyle"
  13. TargetType="Button">
  14. <Setter Property="Template">
  15. <Setter.Value>
  16. <ControlTemplate TargetType="{x:Type Button}">
  17. <Grid>
  18. <VisualStateManager.VisualStateGroups>
  19. <VisualStateGroup x:Name="CommonStates">
  20. <VisualStateGroup.Transitions>
  21. <VisualTransition GeneratedDuration="" />
  22. <VisualTransition GeneratedDuration="0:0:0.1"
  23. To="MouseOver" />
  24. <VisualTransition GeneratedDuration="0:0:0.1"
  25. To="Pressed" />
  26. </VisualStateGroup.Transitions>
  27. <VisualState x:Name="Normal" />
  28. <VisualState x:Name="MouseOver">
  29. <Storyboard>
  30. <ColorAnimationUsingKeyFrames BeginTime=""
  31. Duration="00:00:00.001"
  32. Storyboard.TargetName="BackgroundGradient"
  33. Storyboard.TargetProperty="(Border.Background).
  34. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  35. <SplineColorKeyFrame KeyTime=""
  36. Value="#F2FFFFFF" />
  37. </ColorAnimationUsingKeyFrames>
  38. <ColorAnimationUsingKeyFrames BeginTime=""
  39. Duration="00:00:00.001"
  40. Storyboard.TargetName="BackgroundGradient"
  41. Storyboard.TargetProperty="(Border.Background).
  42. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  43. <SplineColorKeyFrame KeyTime=""
  44. Value="#CCFFFFFF" />
  45. </ColorAnimationUsingKeyFrames>
  46. <ColorAnimation Duration=""
  47. To="#FF448DCA"
  48. Storyboard.TargetProperty="(Border.Background).
  49. (SolidColorBrush.Color)"
  50. Storyboard.TargetName="Background" />
  51. <ColorAnimationUsingKeyFrames BeginTime=""
  52. Duration="00:00:00.001"
  53. Storyboard.TargetName="BackgroundGradient"
  54. Storyboard.TargetProperty="(Border.Background).
  55. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  56. <SplineColorKeyFrame KeyTime=""
  57. Value="#7FFFFFFF" />
  58. </ColorAnimationUsingKeyFrames>
  59. </Storyboard>
  60. </VisualState>
  61. <VisualState x:Name="Pressed">
  62. <Storyboard>
  63. <ColorAnimationUsingKeyFrames BeginTime=""
  64. Duration="00:00:00.001"
  65. Storyboard.TargetName="Background"
  66. Storyboard.TargetProperty="(Border.Background).
  67. (SolidColorBrush.Color)">
  68. <SplineColorKeyFrame KeyTime=""
  69. Value="#FF448DCA" />
  70. </ColorAnimationUsingKeyFrames>
  71. <DoubleAnimationUsingKeyFrames BeginTime=""
  72. Duration="00:00:00.001"
  73. Storyboard.TargetProperty="(UIElement.Opacity)"
  74. Storyboard.TargetName="Highlight">
  75. <SplineDoubleKeyFrame KeyTime=""
  76. Value="" />
  77. </DoubleAnimationUsingKeyFrames>
  78. <ColorAnimationUsingKeyFrames BeginTime=""
  79. Duration="00:00:00.001"
  80. Storyboard.TargetName="BackgroundGradient"
  81. Storyboard.TargetProperty="(Border.Background).
  82. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  83. <SplineColorKeyFrame KeyTime=""
  84. Value="#F4FFFFFF" />
  85. </ColorAnimationUsingKeyFrames>
  86. <ColorAnimationUsingKeyFrames BeginTime=""
  87. Duration="00:00:00.001"
  88. Storyboard.TargetName="BackgroundGradient"
  89. Storyboard.TargetProperty="(Border.Background).
  90. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  91. <SplineColorKeyFrame KeyTime=""
  92. Value="#EAFFFFFF" />
  93. </ColorAnimationUsingKeyFrames>
  94. <ColorAnimationUsingKeyFrames BeginTime=""
  95. Duration="00:00:00.001"
  96. Storyboard.TargetName="BackgroundGradient"
  97. Storyboard.TargetProperty="(Border.Background).
  98. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  99. <SplineColorKeyFrame KeyTime=""
  100. Value="#C6FFFFFF" />
  101. </ColorAnimationUsingKeyFrames>
  102. <ColorAnimationUsingKeyFrames BeginTime=""
  103. Duration="00:00:00.001"
  104. Storyboard.TargetName="BackgroundGradient"
  105. Storyboard.TargetProperty="(Border.Background).
  106. (GradientBrush.GradientStops)[].(GradientStop.Color)">
  107. <SplineColorKeyFrame KeyTime=""
  108. Value="#6BFFFFFF" />
  109. </ColorAnimationUsingKeyFrames>
  110. </Storyboard>
  111. </VisualState>
  112. <VisualState x:Name="Disabled" />
  113. </VisualStateGroup>
  114. </VisualStateManager.VisualStateGroups>
  115. <Grid Background="#11FFFFFF"
  116. FlowDirection="LeftToRight"
  117. HorizontalAlignment="Center"
  118. Height=""
  119. Margin=""
  120. VerticalAlignment="Center"
  121. Width="">
  122. <Grid.ColumnDefinitions>
  123. <ColumnDefinition Width="20*" />
  124. <ColumnDefinition Width="20*" />
  125. <ColumnDefinition Width="20*" />
  126. <ColumnDefinition Width="20*" />
  127. </Grid.ColumnDefinitions>
  128. <Grid.RowDefinitions>
  129. <RowDefinition Height="23*" />
  130. <RowDefinition Height="19*" />
  131. <RowDefinition Height="19*" />
  132. <RowDefinition Height="19*" />
  133. </Grid.RowDefinitions>
  134. <Border x:Name="Highlight"
  135. BorderThickness=""
  136. Grid.ColumnSpan=""
  137. CornerRadius="0,0,1,1"
  138. Margin="-1"
  139. Opacity=""
  140. Grid.Row=""
  141. Grid.RowSpan="">
  142. <Border.BorderBrush>
  143. <SolidColorBrush Color="{DynamicResource ControlPressedColor}" />
  144. </Border.BorderBrush>
  145. </Border>
  146. <Border x:Name="Background"
  147. BorderBrush="#FFFFFFFF"
  148. BorderThickness=""
  149. Grid.ColumnSpan=""
  150. CornerRadius=".5"
  151. Margin="0,-1,0,0"
  152. Opacity=""
  153. Grid.Row=""
  154. Grid.RowSpan="">
  155. <Border.Background>
  156. <SolidColorBrush Color="{DynamicResource ControlDarkColor}" />
  157. </Border.Background>
  158. </Border>
  159. <Border x:Name="BackgroundGradient"
  160. BorderBrush="#BF000000"
  161. BorderThickness=""
  162. Grid.ColumnSpan=""
  163. CornerRadius=".5"
  164. Margin="0,-1,0,0"
  165. Opacity=""
  166. Grid.Row=""
  167. Grid.RowSpan="">
  168. <Border.Background>
  169. <LinearGradientBrush EndPoint=".7,1"
  170. StartPoint=".7,0">
  171. <GradientStop Color="#FFFFFFFF"
  172. Offset="" />
  173. <GradientStop Color="#F9FFFFFF"
  174. Offset="0.375" />
  175. <GradientStop Color="#E5FFFFFF"
  176. Offset="0.625" />
  177. <GradientStop Color="#C6FFFFFF"
  178. Offset="" />
  179. </LinearGradientBrush>
  180. </Border.Background>
  181. </Border>
  182. <Rectangle Grid.ColumnSpan=""
  183. Grid.RowSpan=""
  184. StrokeThickness="">
  185. <Rectangle.Fill>
  186. <LinearGradientBrush EndPoint="0,1"
  187. StartPoint="0,0">
  188. <GradientStop Color="{DynamicResource HeaderTopColor}" />
  189. <GradientStop Color="{DynamicResource ControlMediumColor}"
  190. Offset="" />
  191. </LinearGradientBrush>
  192. </Rectangle.Fill>
  193. <Rectangle.Stroke>
  194. <LinearGradientBrush EndPoint="0.48,-1"
  195. StartPoint="0.48,1.25">
  196. <GradientStop Color="#FF494949" />
  197. <GradientStop Color="#FF9F9F9F"
  198. Offset="" />
  199. </LinearGradientBrush>
  200. </Rectangle.Stroke>
  201. </Rectangle>
  202. <Path Fill="#FF2F2F2F"
  203. Grid.Row=""
  204. Grid.Column=""
  205. Grid.RowSpan=""
  206. Grid.ColumnSpan=""
  207. HorizontalAlignment="Center"
  208. VerticalAlignment="Center"
  209. RenderTransformOrigin="0.5,0.5"
  210. Margin="4,3,4,3"
  211. Stretch="Fill"
  212. Data="M11.426758,8.4305077 L11.749023,8.4305077
  213. L11.,16.331387 L10.,16.331387
  214. L10.,10.299648 L9.,11.298672
  215. L9.,10.294277 C9.,10.090176
  216. 9.9094238,9.8090878 10.365967,9.4510155
  217. C10.,9.0929432 11.176106,8.7527733
  218. 11.426758,8.4305077 z M14.,8.4305077
  219. L18.,8.4305077 L18.,9.3435936
  220. L15.,9.3435936 L15.,11.255703
  221. C15.,11.058764 16.27293,10.960293
  222. 16.681133,10.960293 C17.,10.960293
  223. 17.969301,11.178717 18.354229,11.615566
  224. C18.,12.052416 18.931622,12.673672
  225. 18.931622,13.479336 C18.,15.452317
  226. 18.052553,16.438808 16.294415,16.438808
  227. C15.,16.438808 14.951641,16.234707
  228. 14.468243,15.826504 L14.,14.929531
  229. C15.,15.326992 15.837872,15.525723
  230. 16.289043,15.525723 C17.,15.525723
  231. 17.803692,14.895514 17.803692,13.635098
  232. C17.,12.460618 17.305971,11.873379
  233. 16.310528,11.873379 C15.,11.873379
  234. 15.399232,12.079271 15.016094,12.491055
  235. L14.,12.238613 z" />
  236. <Ellipse Grid.ColumnSpan=""
  237. Fill="#FFFFFFFF"
  238. HorizontalAlignment="Center"
  239. Height=""
  240. StrokeThickness=""
  241. VerticalAlignment="Center"
  242. Width="" />
  243. <Border x:Name="DisabledVisual"
  244. BorderBrush="#B2FFFFFF"
  245. BorderThickness=""
  246. Grid.ColumnSpan=""
  247. CornerRadius="0,0,.5,.5"
  248. Opacity=""
  249. Grid.Row=""
  250. Grid.RowSpan="" />
  251. </Grid>
  252. </Grid>
  253. </ControlTemplate>
  254. </Setter.Value>
  255. </Setter>
  256. </Style>
  257.  
  258. <Style TargetType="{x:Type DatePicker}">
  259. <Setter Property="Foreground"
  260. Value="#FF333333" />
  261. <Setter Property="IsTodayHighlighted"
  262. Value="True" />
  263. <Setter Property="SelectedDateFormat"
  264. Value="Short" />
  265. <Setter Property="Padding"
  266. Value="" />
  267. <Setter Property="BorderThickness"
  268. Value="" />
  269. <Setter Property="HorizontalContentAlignment"
  270. Value="Stretch" />
  271. <!--Set CalendarStyle to DatePickerCalendarStyle.-->
  272. <Setter Property="CalendarStyle"
  273. Value="{DynamicResource DatePickerCalendarStyle}" />
  274. <Setter Property="Template">
  275. <Setter.Value>
  276. <ControlTemplate TargetType="{x:Type DatePicker}">
  277. <Border BorderThickness="{TemplateBinding BorderThickness}"
  278. Padding="{TemplateBinding Padding}">
  279. <Border.BorderBrush>
  280. <LinearGradientBrush EndPoint="0.5,1"
  281. StartPoint="0.5,0">
  282. <GradientStop Color="{DynamicResource BorderLightColor}"
  283. Offset="" />
  284. <GradientStop Color="{DynamicResource BorderDarkColor}"
  285. Offset="" />
  286. </LinearGradientBrush>
  287. </Border.BorderBrush>
  288. <Border.Background>
  289. <LinearGradientBrush EndPoint="0.5,1"
  290. StartPoint="0.5,0">
  291. <GradientStop Color="{DynamicResource HeaderTopColor}"
  292. Offset="" />
  293. <GradientStop Color="{DynamicResource ControlMediumColor}"
  294. Offset="" />
  295. </LinearGradientBrush>
  296. </Border.Background>
  297. <VisualStateManager.VisualStateGroups>
  298. <VisualStateGroup x:Name="CommonStates">
  299. <VisualState x:Name="Normal" />
  300. <VisualState x:Name="Disabled">
  301. <Storyboard>
  302. <DoubleAnimation Duration=""
  303. To=""
  304. Storyboard.TargetProperty="Opacity"
  305. Storyboard.TargetName="PART_DisabledVisual" />
  306. </Storyboard>
  307. </VisualState>
  308. </VisualStateGroup>
  309. </VisualStateManager.VisualStateGroups>
  310. <Grid x:Name="PART_Root"
  311. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  312. VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  313. <Grid.ColumnDefinitions>
  314. <ColumnDefinition Width="*" />
  315. <ColumnDefinition Width="Auto" />
  316. </Grid.ColumnDefinitions>
  317. <Button x:Name="PART_Button"
  318. Grid.Column=""
  319. Foreground="{TemplateBinding Foreground}"
  320. Focusable="False"
  321. HorizontalAlignment="Left"
  322. Margin="3,0,3,0"
  323. Grid.Row=""
  324. Style="{StaticResource DropDownButtonStyle}"
  325. VerticalAlignment="Top" />
  326. <DatePickerTextBox x:Name="PART_TextBox"
  327. Grid.Column=""
  328. Foreground="{TemplateBinding Foreground}"
  329. Focusable="{TemplateBinding Focusable}"
  330. HorizontalContentAlignment="Stretch"
  331. Grid.Row=""
  332. VerticalContentAlignment="Stretch" />
  333. <Grid x:Name="PART_DisabledVisual"
  334. Grid.ColumnSpan=""
  335. Grid.Column=""
  336. IsHitTestVisible="False"
  337. Opacity=""
  338. Grid.Row="">
  339. <Grid.ColumnDefinitions>
  340. <ColumnDefinition Width="*" />
  341. <ColumnDefinition Width="Auto" />
  342. </Grid.ColumnDefinitions>
  343. <Rectangle Grid.Column=""
  344. Fill="#A5FFFFFF"
  345. RadiusY=""
  346. Grid.Row=""
  347. RadiusX="" />
  348. <Rectangle Grid.Column=""
  349. Fill="#A5FFFFFF"
  350. Height=""
  351. Margin="3,0,3,0"
  352. RadiusY=""
  353. Grid.Row=""
  354. RadiusX=""
  355. Width="" />
  356. <Popup x:Name="PART_Popup"
  357. AllowsTransparency="True"
  358. Placement="Bottom"
  359. PlacementTarget="{Binding ElementName=PART_TextBox}"
  360. StaysOpen="False" />
  361. </Grid>
  362. </Grid>
  363. </Border>
  364. </ControlTemplate>
  365. </Setter.Value>
  366. </Setter>
  367. </Style>
  368.  
  369. </ResourceDictionary>

ControlTemplate in WPF —— DatePicker的更多相关文章

  1. WPF DatePicker默认显示当前日期,格式化为年月日

    原文:WPF DatePicker默认显示当前日期 WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里 ...

  2. WPF DatePicker默认显示当前日期

    WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里,具体请看下面.     1.方法一:     my ...

  3. wpf datepicker 样式

    在项目中用到的 <Style TargetType="{x:Type DatePicker}"> <Setter Property="Foregroun ...

  4. WPF DatePicker只显示年和月 修改:可以只显示年

    最近的项目,查询时只需要年和月,不需要日,因此需要对原有的DatePicker进行修改,查询了网上的内容,最终从一篇帖子里看到了添加附加属性的方法,地址是http://stackoverflow.co ...

  5. Wpf DatePicker 水印修改为中文

    效果图: 在App.cs添加如下代码: protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Event ...

  6. WPF: DatePicker

    获取DatePicker:date_Start上显示的时间date_Start.SelectedDate 比较两个dateTime类型的时间: DateTime StartDate =Convert. ...

  7. WPF DatePicker 添加水印效果

    这个控件没有水印属性,依然使用依赖属性解决 public class DatePickerHelper { public static object GetWatermark(DependencyOb ...

  8. WPF DatePicker 默认显示当前时间

    两种方法: 1.通过后台赋值: this.datePicker.SelectedDate = DateTime.Now; 2.前台控件的属性直接赋值 xmlns:sys="clr-names ...

  9. WPF DatePicker日期控件只显示年月

    1.需要引用2个类,第一个类DatePickerCalendar public class DatePickerCalendar { public static readonly Dependency ...

随机推荐

  1. 31、NTP时间服务器

    1.NTP简介 NTP服务器顾名思义就是时间同步服务器(Network Time Protocol),Linux下的ntp服务器配置相对来说都比较容易,但在Linux下有一个弊端,不同时区或者说是时间 ...

  2. CentOS7 配置NFS(Network File System)及其使用

    1.       服务端配置 1.1.    安装NFS yum -y install nfs* 1.2.    查看是否安装了NFS与RPCBIND rpm -qa | grep nfs rpm - ...

  3. 新建swap分区

    1.在一块新盘上创建一个主分区,大小为1G大小. 2.将该硬盘数据变更为82(swap),并进行保存 3.查看是否已经将新建分区更改成了swap分区 4.将/dev/sdb2的标签设置为swap-sd ...

  4. 使用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 ...

  5. 微信小程序let和var以及const有什么区别

    在JavaScript中有三种声明变量的方式:var.let.const. var:声明全局变量,换句话理解就是,声明在for循环中的变量,跳出for循环同样可以使用. for(var i=0;i&l ...

  6. CSS3 选择器——笔记+实战案例(基本选择器、组合选择器、属性选择器、伪类选择器)

    使用CSS3 选择器——笔记 CSS通过选择器控制HTML元素,CSS选择器对网页对象可以实现一对一.一对多或者多对一的匹配. 一.CSS3选择器分类 CSS选择器在CSS2.1选择器的基础上新增了属 ...

  7. Python 操作 MySQL 数据库Ⅳ

    执行事务 事务机制可以确保数据一致性. 事务应该具有4个属性:原子性.一致性.隔离性.持久性.这四个属性通常称为ACID特性. 原子性(atomicity).一个事务是一个不可分割的工作单位,事务中包 ...

  8. Python 异常处理Ⅱ

    异常处理 捕捉异常可以使用try/except语句. try/except语句用来检测try语句块中的错误,从而让except语句捕获异常信息并处理. 如果你不想在异常发生时结束你的程序,只需在try ...

  9. Java架构师面试题——JVM性能调优

    JVM内存调优 对JVM内存的系统级的调优主要的目的是减少GC的频率和Full GC的次数. 1.Full GC 会对整个堆进行整理,包括Young.Tenured和Perm.Full GC因为需要对 ...

  10. count(列) count(*)

    总结:但是真的结论是这样的么.其实不然.其实在数据库中count(*)和count(列)根本就是不等价的,count(*)是针对于全表的,而count(列)是针对于某一列的,如果此列值为空的话,cou ...