DatePickerStyle.xaml 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style x:Key="TextBolockTriggers" TargetType="Grid">
  4. <Style.Triggers>
  5. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周六">
  6. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush3}"/>
  7. </DataTrigger>
  8. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周日">
  9. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush3}"/>
  10. </DataTrigger>
  11. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周一">
  12. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush4}"/>
  13. </DataTrigger>
  14. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周二">
  15. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush4}"/>
  16. </DataTrigger>
  17. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周三">
  18. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush4}"/>
  19. </DataTrigger>
  20. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周四">
  21. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush4}"/>
  22. </DataTrigger>
  23. <DataTrigger Binding="{Binding ElementName=txtBlock, Path=Text}" Value="周五">
  24. <Setter Property="Background" Value="{DynamicResource MuchinfoBrush4}"/>
  25. </DataTrigger>
  26. </Style.Triggers>
  27. </Style>
  28. <!--日历主体样式表-->
  29. <Style x:Key="CalendarItemStyle"
  30. TargetType="{x:Type CalendarItem}">
  31. <Setter Property="Template">
  32. <Setter.Value>
  33. <ControlTemplate TargetType="{x:Type CalendarItem}">
  34. <ControlTemplate.Resources>
  35. <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
  36. <!--日历星期几的绑定样式,我格式化成周一,周二等-->
  37. <Grid Height="30"
  38. Width="50"
  39. Style="{StaticResource TextBolockTriggers}"
  40. Margin="1"
  41. HorizontalAlignment="Center"
  42. VerticalAlignment="Center">
  43. <TextBlock x:Name="txtBlock"
  44. FontSize="13"
  45. Foreground="white"
  46. FontFamily="微软雅黑"
  47. HorizontalAlignment="Center"
  48. Text="{Binding StringFormat=周{0}}"
  49. VerticalAlignment="Center" />
  50. </Grid>
  51. </DataTemplate>
  52. </ControlTemplate.Resources>
  53. <Grid x:Name="PART_Root">
  54. <Grid.Resources>
  55. <!--设置日历控件 IsEnable=false 时的不可用遮罩层颜色,并且会播放过渡动画-->
  56. <SolidColorBrush x:Key="DisabledColor"
  57. Color="#A5FFFFFF" />
  58. </Grid.Resources>
  59. <VisualStateManager.VisualStateGroups>
  60. <VisualStateGroup x:Name="CommonStates">
  61. <VisualState x:Name="Normal" />
  62. <VisualState x:Name="Disabled">
  63. <!--设置日历控件 IsEnable=false 时遮罩层透明度0-1变色动画-->
  64. <Storyboard>
  65. <DoubleAnimation Duration="0"
  66. To="1"
  67. Storyboard.TargetProperty="Opacity"
  68. Storyboard.TargetName="PART_DisabledVisual" />
  69. </Storyboard>
  70. </VisualState>
  71. </VisualStateGroup>
  72. </VisualStateManager.VisualStateGroups>
  73. <Border BorderBrush="#cfcfcf"
  74. BorderThickness="0"
  75. Background="{TemplateBinding Background}"
  76. CornerRadius="2">
  77. <Border>
  78. <Grid>
  79. <Grid.Resources>
  80. <!--日历头左箭头按钮样式模版-->
  81. <ControlTemplate x:Key="PreviousButtonTemplate"
  82. TargetType="{x:Type Button}">
  83. <!--鼠标悬停在左箭头按钮上时改变鼠标指针样式-->
  84. <Grid Cursor="Hand">
  85. <VisualStateManager.VisualStateGroups>
  86. <VisualStateGroup x:Name="CommonStates">
  87. <VisualState x:Name="Normal" />
  88. <VisualState x:Name="MouseOver">
  89. <!--鼠标悬停在左箭头按钮上时左箭头颜色变化动画-->
  90. <Storyboard>
  91. <ColorAnimation Duration="0"
  92. To="#ffffffff"
  93. Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
  94. Storyboard.TargetName="path" />
  95. </Storyboard>
  96. </VisualState>
  97. <VisualState x:Name="Disabled">
  98. <Storyboard>
  99. <DoubleAnimation Duration="0"
  100. To=".5"
  101. Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
  102. Storyboard.TargetName="path" />
  103. </Storyboard>
  104. </VisualState>
  105. </VisualStateGroup>
  106. </VisualStateManager.VisualStateGroups>
  107. <!--左箭头整个区域矩形块-->
  108. <Rectangle Fill="{DynamicResource MuchinfoBrush3}"
  109. Opacity="1"
  110. Stretch="Fill" />
  111. <Grid>
  112. <!--左箭头-->
  113. <Path x:Name="path"
  114. Data="M288.75,232.25 L288.75,240.625 L283,236.625 z"
  115. Fill="#e0e0e0"
  116. HorizontalAlignment="Left"
  117. Height="15"
  118. Width="15"
  119. Margin="20,0,0,0"
  120. Stretch="Fill"
  121. VerticalAlignment="Center" />
  122. </Grid>
  123. </Grid>
  124. </ControlTemplate>
  125. <!--日历头右箭头按钮样式模版,这块跟左箭头样式模版没什么区别-->
  126. <ControlTemplate x:Key="NextButtonTemplate"
  127. TargetType="{x:Type Button}">
  128. <Grid Cursor="Hand">
  129. <VisualStateManager.VisualStateGroups>
  130. <VisualStateGroup x:Name="CommonStates">
  131. <VisualState x:Name="Normal" />
  132. <VisualState x:Name="MouseOver">
  133. <Storyboard>
  134. <ColorAnimation Duration="0"
  135. To="#ffffffff"
  136. Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
  137. Storyboard.TargetName="path" />
  138. </Storyboard>
  139. </VisualState>
  140. <VisualState x:Name="Disabled">
  141. <Storyboard>
  142. <DoubleAnimation Duration="0"
  143. To=".5"
  144. Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)"
  145. Storyboard.TargetName="path" />
  146. </Storyboard>
  147. </VisualState>
  148. </VisualStateGroup>
  149. </VisualStateManager.VisualStateGroups>
  150. <Rectangle Fill="{DynamicResource MuchinfoBrush3}"
  151. Opacity="1"
  152. Stretch="Fill" />
  153. <Grid>
  154. <Path x:Name="path"
  155. Data="M282.875,231.875 L282.875,240.375 L288.625,236 z"
  156. Fill="#e0e0e0"
  157. HorizontalAlignment="Right"
  158. Height="15"
  159. Width="15"
  160. Margin="0,0,20,0"
  161. Stretch="Fill"
  162. VerticalAlignment="Center" />
  163. </Grid>
  164. </Grid>
  165. </ControlTemplate>
  166. <!--日历头中间年按钮样式模版-->
  167. <ControlTemplate x:Key="HeaderButtonTemplate"
  168. TargetType="{x:Type Button}">
  169. <Grid Cursor="Hand">
  170. <VisualStateManager.VisualStateGroups>
  171. <VisualStateGroup x:Name="CommonStates">
  172. <VisualState x:Name="Normal" />
  173. <VisualState x:Name="MouseOver">
  174. <Storyboard>
  175. <ColorAnimation Duration="0"
  176. To="#ffffffff"
  177. Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
  178. Storyboard.TargetName="buttonContent" />
  179. </Storyboard>
  180. </VisualState>
  181. <VisualState x:Name="Disabled">
  182. <Storyboard>
  183. <DoubleAnimation Duration="0"
  184. To=".5"
  185. Storyboard.TargetProperty="Opacity"
  186. Storyboard.TargetName="buttonContent" />
  187. </Storyboard>
  188. </VisualState>
  189. </VisualStateGroup>
  190. </VisualStateManager.VisualStateGroups>
  191. <ContentPresenter x:Name="buttonContent"
  192. ContentTemplate="{TemplateBinding ContentTemplate}"
  193. Content="{TemplateBinding Content}"
  194. TextElement.Foreground="#e0e0e0"
  195. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  196. Margin="1,4,1,9"
  197. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  198. </Grid>
  199. </ControlTemplate>
  200. </Grid.Resources>
  201. <Grid.RowDefinitions>
  202. <!--日历头,左箭头,年,右箭头-->
  203. <RowDefinition Height="Auto" />
  204. <!--日历内容,星期几和具体的日期几号几号-->
  205. <RowDefinition Height="*" />
  206. </Grid.RowDefinitions>
  207. <Grid.ColumnDefinitions>
  208. <!--左箭头-->
  209. <ColumnDefinition Width="Auto" />
  210. <!--年-->
  211. <ColumnDefinition Width="*" />
  212. <!--右箭头-->
  213. <ColumnDefinition Width="Auto" />
  214. </Grid.ColumnDefinitions>
  215. <!--头,左箭头,年,右箭头,整体的背景色-->
  216. <Border Grid.Row="0"
  217. Grid.ColumnSpan="3"
  218. Background="{DynamicResource MuchinfoBrush3}"></Border>
  219. <!--左箭头-->
  220. <Button x:Name="PART_PreviousButton"
  221. Grid.Column="0"
  222. Focusable="False"
  223. HorizontalAlignment="Left"
  224. Grid.Row="0"
  225. Template="{StaticResource PreviousButtonTemplate}" />
  226. <!--年-->
  227. <Button x:Name="PART_HeaderButton"
  228. Grid.Column="1"
  229. FontFamily="微软雅黑"
  230. Focusable="False"
  231. FontSize="17"
  232. HorizontalAlignment="Center"
  233. Grid.Row="0"
  234. Template="{StaticResource HeaderButtonTemplate}"
  235. VerticalAlignment="Center" />
  236. <!--右箭头-->
  237. <Button x:Name="PART_NextButton"
  238. Grid.Column="2"
  239. Focusable="False"
  240. HorizontalAlignment="Right"
  241. Grid.Row="0"
  242. Template="{StaticResource NextButtonTemplate}" />
  243. <!--日期几号几号内容显示-->
  244. <Border Grid.Row="1"
  245. Grid.ColumnSpan="3"
  246. Margin="0"
  247. BorderBrush="#cfcfcf"
  248. BorderThickness="3,0,3,3">
  249. <Grid x:Name="PART_MonthView"
  250. HorizontalAlignment="Center"
  251. Visibility="Visible">
  252. <Grid.ColumnDefinitions>
  253. <ColumnDefinition Width="*" />
  254. <ColumnDefinition Width="*" />
  255. <ColumnDefinition Width="*" />
  256. <ColumnDefinition Width="*" />
  257. <ColumnDefinition Width="*" />
  258. <ColumnDefinition Width="*" />
  259. <ColumnDefinition Width="*" />
  260. </Grid.ColumnDefinitions>
  261. <Grid.RowDefinitions>
  262. <RowDefinition Height="auto" />
  263. <RowDefinition Height="*" />
  264. <RowDefinition Height="*" />
  265. <RowDefinition Height="*" />
  266. <RowDefinition Height="*" />
  267. <RowDefinition Height="*" />
  268. <RowDefinition Height="*" />
  269. </Grid.RowDefinitions>
  270. </Grid>
  271. </Border>
  272. <!--月和年内容显示-->
  273. <Grid x:Name="PART_YearView"
  274. Grid.ColumnSpan="3"
  275. HorizontalAlignment="Center"
  276. Margin="6,-3,7,6"
  277. Grid.Row="1"
  278. Visibility="Hidden"
  279. VerticalAlignment="Center">
  280. <Grid.ColumnDefinitions>
  281. <ColumnDefinition Width="*" />
  282. <ColumnDefinition Width="*" />
  283. <ColumnDefinition Width="*" />
  284. <ColumnDefinition Width="*" />
  285. </Grid.ColumnDefinitions>
  286. <Grid.RowDefinitions>
  287. <RowDefinition Height="*" />
  288. <RowDefinition Height="*" />
  289. <RowDefinition Height="*" />
  290. </Grid.RowDefinitions>
  291. </Grid>
  292. </Grid>
  293. </Border>
  294. </Border>
  295. <!--日历不可用的遮罩层-->
  296. <Rectangle x:Name="PART_DisabledVisual"
  297. Fill="{StaticResource DisabledColor}"
  298. Opacity="0"
  299. RadiusY="2"
  300. RadiusX="2"
  301. Stretch="Fill"
  302. Stroke="{StaticResource DisabledColor}"
  303. StrokeThickness="1"
  304. Visibility="Collapsed" />
  305. </Grid>
  306. <!--触发器属性-->
  307. <ControlTemplate.Triggers>
  308. <Trigger Property="IsEnabled"
  309. Value="False">
  310. <Setter Property="Visibility"
  311. TargetName="PART_DisabledVisual"
  312. Value="Visible" />
  313. </Trigger>
  314. <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
  315. Value="Year">
  316. <Setter Property="Visibility"
  317. TargetName="PART_MonthView"
  318. Value="Hidden" />
  319. <Setter Property="Visibility"
  320. TargetName="PART_YearView"
  321. Value="Visible" />
  322. </DataTrigger>
  323. <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}"
  324. Value="Decade">
  325. <Setter Property="Visibility"
  326. TargetName="PART_MonthView"
  327. Value="Hidden" />
  328. <Setter Property="Visibility"
  329. TargetName="PART_YearView"
  330. Value="Visible" />
  331. </DataTrigger>
  332. </ControlTemplate.Triggers>
  333. </ControlTemplate>
  334. </Setter.Value>
  335. </Setter>
  336. </Style>
  337. <!--单个几号几号按钮的样式模版-->
  338. <Style x:Key="CalendarDayButtonStyle"
  339. TargetType="{x:Type CalendarDayButton}">
  340. <Setter Property="Margin"
  341. Value="1" />
  342. <Setter Property="MinWidth"
  343. Value="5" />
  344. <Setter Property="MinHeight"
  345. Value="5" />
  346. <Setter Property="FontSize"
  347. Value="15" />
  348. <Setter Property="FontFamily"
  349. Value="微软雅黑" />
  350. <Setter Property="HorizontalContentAlignment"
  351. Value="Center" />
  352. <Setter Property="VerticalContentAlignment"
  353. Value="Center" />
  354. <Setter Property="Template">
  355. <Setter.Value>
  356. <ControlTemplate TargetType="{x:Type CalendarDayButton}">
  357. <Grid>
  358. <VisualStateManager.VisualStateGroups>
  359. <VisualStateGroup x:Name="CommonStates">
  360. <VisualStateGroup.Transitions>
  361. <VisualTransition GeneratedDuration="0:0:0.1" />
  362. </VisualStateGroup.Transitions>
  363. <VisualState x:Name="Normal" />
  364. <!--悬停的颜色动画-->
  365. <VisualState x:Name="MouseOver">
  366. <Storyboard>
  367. <DoubleAnimation Duration="0"
  368. To="0.5"
  369. Storyboard.TargetProperty="Opacity"
  370. Storyboard.TargetName="HighlightBackground" />
  371. </Storyboard>
  372. </VisualState>
  373. <!--按下后动画-->
  374. <VisualState x:Name="Pressed">
  375. <Storyboard>
  376. <DoubleAnimation Duration="0"
  377. To="0.5"
  378. Storyboard.TargetProperty="Opacity"
  379. Storyboard.TargetName="HighlightBackground" />
  380. </Storyboard>
  381. </VisualState>
  382. <!--不可用动画-->
  383. <VisualState x:Name="Disabled">
  384. <Storyboard>
  385. <DoubleAnimation Duration="0"
  386. To="0"
  387. Storyboard.TargetProperty="Opacity"
  388. Storyboard.TargetName="HighlightBackground" />
  389. <DoubleAnimation Duration="0"
  390. To=".35"
  391. Storyboard.TargetProperty="Opacity"
  392. Storyboard.TargetName="NormalText" />
  393. </Storyboard>
  394. </VisualState>
  395. </VisualStateGroup>
  396. <VisualStateGroup x:Name="SelectionStates">
  397. <VisualStateGroup.Transitions>
  398. <VisualTransition GeneratedDuration="0" />
  399. </VisualStateGroup.Transitions>
  400. <VisualState x:Name="Unselected" />
  401. <!--选中某日期的样式-->
  402. <VisualState x:Name="Selected">
  403. <Storyboard>
  404. <DoubleAnimation Duration="0"
  405. To=".75"
  406. Storyboard.TargetProperty="Opacity"
  407. Storyboard.TargetName="SelectedBackground" />
  408. <ColorAnimation Duration="0"
  409. To="white"
  410. Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
  411. Storyboard.TargetName="NormalText" />
  412. </Storyboard>
  413. </VisualState>
  414. </VisualStateGroup>
  415. <VisualStateGroup x:Name="CalendarButtonFocusStates">
  416. <VisualStateGroup.Transitions>
  417. <VisualTransition GeneratedDuration="0" />
  418. </VisualStateGroup.Transitions>
  419. <VisualState x:Name="CalendarButtonFocused">
  420. <Storyboard>
  421. <ObjectAnimationUsingKeyFrames Duration="0"
  422. Storyboard.TargetProperty="Visibility"
  423. Storyboard.TargetName="DayButtonFocusVisual">
  424. <DiscreteObjectKeyFrame KeyTime="0">
  425. <DiscreteObjectKeyFrame.Value>
  426. <Visibility>Visible</Visibility>
  427. </DiscreteObjectKeyFrame.Value>
  428. </DiscreteObjectKeyFrame>
  429. </ObjectAnimationUsingKeyFrames>
  430. </Storyboard>
  431. </VisualState>
  432. <VisualState x:Name="CalendarButtonUnfocused">
  433. <Storyboard>
  434. <ObjectAnimationUsingKeyFrames Duration="0"
  435. Storyboard.TargetProperty="Visibility"
  436. Storyboard.TargetName="DayButtonFocusVisual">
  437. <DiscreteObjectKeyFrame KeyTime="0">
  438. <DiscreteObjectKeyFrame.Value>
  439. <Visibility>Collapsed</Visibility>
  440. </DiscreteObjectKeyFrame.Value>
  441. </DiscreteObjectKeyFrame>
  442. </ObjectAnimationUsingKeyFrames>
  443. </Storyboard>
  444. </VisualState>
  445. </VisualStateGroup>
  446. <VisualStateGroup x:Name="ActiveStates">
  447. <VisualStateGroup.Transitions>
  448. <VisualTransition GeneratedDuration="0" />
  449. </VisualStateGroup.Transitions>
  450. <VisualState x:Name="Active" />
  451. <VisualState x:Name="Inactive">
  452. <Storyboard>
  453. <ColorAnimation Duration="0"
  454. To="#b4b3b3"
  455. Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
  456. Storyboard.TargetName="NormalText" />
  457. </Storyboard>
  458. </VisualState>
  459. </VisualStateGroup>
  460. <VisualStateGroup x:Name="DayStates">
  461. <VisualStateGroup.Transitions>
  462. <VisualTransition GeneratedDuration="0" />
  463. </VisualStateGroup.Transitions>
  464. <VisualState x:Name="RegularDay" />
  465. <!--今天的样式-->
  466. <VisualState x:Name="Today">
  467. <Storyboard>
  468. <DoubleAnimation Duration="0"
  469. To="1"
  470. Storyboard.TargetProperty="Opacity"
  471. Storyboard.TargetName="TodayBackground" />
  472. <ColorAnimation Duration="0"
  473. To="#666666"
  474. Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
  475. Storyboard.TargetName="NormalText" />
  476. <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
  477. Storyboard.TargetName="imgToday">
  478. <DiscreteObjectKeyFrame KeyTime="0">
  479. <DiscreteObjectKeyFrame.Value>
  480. <Visibility>Visible</Visibility>
  481. </DiscreteObjectKeyFrame.Value>
  482. </DiscreteObjectKeyFrame>
  483. </ObjectAnimationUsingKeyFrames>
  484. </Storyboard>
  485. </VisualState>
  486. </VisualStateGroup>
  487. <!--过期日期的-->
  488. <VisualStateGroup x:Name="BlackoutDayStates">
  489. <VisualStateGroup.Transitions>
  490. <VisualTransition GeneratedDuration="0" />
  491. </VisualStateGroup.Transitions>
  492. <VisualState x:Name="NormalDay" />
  493. <VisualState x:Name="BlackoutDay">
  494. <Storyboard>
  495. <DoubleAnimation Duration="0"
  496. To=".2"
  497. Storyboard.TargetProperty="Opacity"
  498. Storyboard.TargetName="Blackout" />
  499. </Storyboard>
  500. </VisualState>
  501. </VisualStateGroup>
  502. </VisualStateManager.VisualStateGroups>
  503. <Border BorderBrush="#bbbbbb"
  504. BorderThickness="1">
  505. <Border BorderBrush="white"
  506. BorderThickness="2,2,0,0"
  507. Margin="1,1,0,0"></Border>
  508. </Border>
  509. <Rectangle x:Name="TodayBackground"
  510. Fill="#c6c6c6"
  511. Opacity="0"
  512. RadiusY="1"
  513. RadiusX="1" />
  514. <Rectangle x:Name="SelectedBackground"
  515. Fill="{DynamicResource MuchinfoBrush3}"
  516. Opacity="0"
  517. RadiusY="1"
  518. RadiusX="1" />
  519. <Border BorderBrush="{TemplateBinding BorderBrush}"
  520. BorderThickness="{TemplateBinding BorderThickness}"
  521. Background="{TemplateBinding Background}" />
  522. <Rectangle x:Name="HighlightBackground"
  523. Fill="{DynamicResource MuchinfoBrush57}"
  524. Opacity="0"
  525. RadiusY="1"
  526. RadiusX="1" />
  527. <ContentPresenter x:Name="NormalText"
  528. TextElement.Foreground="#666666"
  529. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  530. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  531. <Path x:Name="Blackout"
  532. 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"
  533. Fill="#FF000000"
  534. HorizontalAlignment="Stretch"
  535. Margin="3"
  536. Opacity="0"
  537. RenderTransformOrigin="0.5,0.5"
  538. Stretch="Fill"
  539. VerticalAlignment="Stretch" />
  540. <Rectangle x:Name="DayButtonFocusVisual"
  541. IsHitTestVisible="false"
  542. RadiusY="1"
  543. RadiusX="1"
  544. Stroke="{DynamicResource MuchinfoBrush3}"
  545. Visibility="Collapsed" />
  546. <Image x:Name="imgToday"
  547. Width="32"
  548. Height="22"
  549. Source="/Muchinfo.MTPClient;component/Images/today.png"
  550. VerticalAlignment="Top"
  551. HorizontalAlignment="Left"
  552. Visibility="Hidden" />
  553. </Grid>
  554. </ControlTemplate>
  555. </Setter.Value>
  556. </Setter>
  557. </Style>
  558. <Style x:Key="CalendarButtonStyle"
  559. TargetType="{x:Type CalendarButton}">
  560. <Setter Property="Background"
  561. Value="{DynamicResource MuchinfoBrush57}" />
  562. <Setter Property="MinWidth"
  563. Value="50" />
  564. <Setter Property="MinHeight"
  565. Value="50" />
  566. <Setter Property="Margin"
  567. Value="2" />
  568. <Setter Property="FontSize"
  569. Value="15" />
  570. <Setter Property="HorizontalContentAlignment"
  571. Value="Center" />
  572. <Setter Property="VerticalContentAlignment"
  573. Value="Center" />
  574. <Setter Property="Template">
  575. <Setter.Value>
  576. <ControlTemplate TargetType="{x:Type CalendarButton}">
  577. <Grid>
  578. <VisualStateManager.VisualStateGroups>
  579. <VisualStateGroup x:Name="CommonStates">
  580. <VisualStateGroup.Transitions>
  581. <VisualTransition GeneratedDuration="0:0:0.1" />
  582. </VisualStateGroup.Transitions>
  583. <VisualState x:Name="Normal" />
  584. <VisualState x:Name="MouseOver">
  585. <Storyboard>
  586. <DoubleAnimation Duration="0"
  587. To=".5"
  588. Storyboard.TargetProperty="Opacity"
  589. Storyboard.TargetName="Background" />
  590. </Storyboard>
  591. </VisualState>
  592. <VisualState x:Name="Pressed">
  593. <Storyboard>
  594. <DoubleAnimation Duration="0"
  595. To=".5"
  596. Storyboard.TargetProperty="Opacity"
  597. Storyboard.TargetName="Background" />
  598. </Storyboard>
  599. </VisualState>
  600. </VisualStateGroup>
  601. <VisualStateGroup x:Name="SelectionStates">
  602. <VisualStateGroup.Transitions>
  603. <VisualTransition GeneratedDuration="0" />
  604. </VisualStateGroup.Transitions>
  605. <VisualState x:Name="Unselected" />
  606. <VisualState x:Name="Selected">
  607. <Storyboard>
  608. <DoubleAnimation Duration="0"
  609. To=".75"
  610. Storyboard.TargetProperty="Opacity"
  611. Storyboard.TargetName="SelectedBackground" />
  612. </Storyboard>
  613. </VisualState>
  614. </VisualStateGroup>
  615. <VisualStateGroup x:Name="ActiveStates">
  616. <VisualStateGroup.Transitions>
  617. <VisualTransition GeneratedDuration="0" />
  618. </VisualStateGroup.Transitions>
  619. <VisualState x:Name="Active" />
  620. <VisualState x:Name="Inactive">
  621. <Storyboard>
  622. <ColorAnimation Duration="0"
  623. To="#FF777777"
  624. Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
  625. Storyboard.TargetName="NormalText" />
  626. </Storyboard>
  627. </VisualState>
  628. </VisualStateGroup>
  629. <VisualStateGroup x:Name="CalendarButtonFocusStates">
  630. <VisualStateGroup.Transitions>
  631. <VisualTransition GeneratedDuration="0" />
  632. </VisualStateGroup.Transitions>
  633. <VisualState x:Name="CalendarButtonFocused">
  634. <Storyboard>
  635. <ObjectAnimationUsingKeyFrames Duration="0"
  636. Storyboard.TargetProperty="Visibility"
  637. Storyboard.TargetName="CalendarButtonFocusVisual">
  638. <DiscreteObjectKeyFrame KeyTime="0">
  639. <DiscreteObjectKeyFrame.Value>
  640. <Visibility>Visible</Visibility>
  641. </DiscreteObjectKeyFrame.Value>
  642. </DiscreteObjectKeyFrame>
  643. </ObjectAnimationUsingKeyFrames>
  644. </Storyboard>
  645. </VisualState>
  646. <VisualState x:Name="CalendarButtonUnfocused">
  647. <Storyboard>
  648. <ObjectAnimationUsingKeyFrames Duration="0"
  649. Storyboard.TargetProperty="Visibility"
  650. Storyboard.TargetName="CalendarButtonFocusVisual">
  651. <DiscreteObjectKeyFrame KeyTime="0">
  652. <DiscreteObjectKeyFrame.Value>
  653. <Visibility>Collapsed</Visibility>
  654. </DiscreteObjectKeyFrame.Value>
  655. </DiscreteObjectKeyFrame>
  656. </ObjectAnimationUsingKeyFrames>
  657. </Storyboard>
  658. </VisualState>
  659. </VisualStateGroup>
  660. </VisualStateManager.VisualStateGroups>
  661. <Rectangle x:Name="SelectedBackground"
  662. Fill="{TemplateBinding Background}"
  663. Opacity="0"
  664. RadiusY="1"
  665. RadiusX="1" />
  666. <Rectangle x:Name="Background"
  667. Fill="{TemplateBinding Background}"
  668. Opacity="0"
  669. RadiusY="1"
  670. RadiusX="1" />
  671. <ContentPresenter x:Name="NormalText"
  672. TextElement.Foreground="#FF333333"
  673. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  674. Margin="1,0,1,1"
  675. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  676. <Rectangle x:Name="CalendarButtonFocusVisual"
  677. IsHitTestVisible="false"
  678. RadiusY="1"
  679. RadiusX="1"
  680. Stroke="{DynamicResource MuchinfoBrush3}"
  681. Visibility="Collapsed" />
  682. </Grid>
  683. <ControlTemplate.Triggers>
  684. <Trigger Property="IsFocused"
  685. Value="True">
  686. <Setter Property="Visibility"
  687. TargetName="CalendarButtonFocusVisual"
  688. Value="Visible" />
  689. </Trigger>
  690. </ControlTemplate.Triggers>
  691. </ControlTemplate>
  692. </Setter.Value>
  693. </Setter>
  694. </Style>
  695. <Style x:Key="CalendarStyle"
  696. TargetType="{x:Type Calendar}">
  697. <!--日历控件的背景色,也可以改成绑定的-->
  698. <Setter Property="Background"
  699. Value="#f6f6f6" />
  700. <Setter Property="Template">
  701. <Setter.Value>
  702. <ControlTemplate TargetType="{x:Type Calendar}">
  703. <StackPanel x:Name="PART_Root"
  704. HorizontalAlignment="Center"
  705. VerticalAlignment="Center">
  706. <!--这个是日历控件的主体元件,也是内部元件PART_CalendarItem名称不要更改,可以改它的其它样式属性-->
  707. <CalendarItem x:Name="PART_CalendarItem"
  708. BorderBrush="{TemplateBinding BorderBrush}"
  709. BorderThickness="{TemplateBinding BorderThickness}"
  710. Background="{TemplateBinding Background}"
  711. Style="{TemplateBinding CalendarItemStyle}"
  712. Height="240"
  713. Width="240"
  714. HorizontalAlignment="Stretch"
  715. VerticalAlignment="Stretch" />
  716. </StackPanel>
  717. </ControlTemplate>
  718. </Setter.Value>
  719. </Setter>
  720. <Setter Property="CalendarItemStyle" Value="{StaticResource CalendarItemStyle}"/>
  721. <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyle}"/>
  722. <Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonStyle}"/>
  723. </Style>
  724. </ResourceDictionary>