CalendarDatePicker.xaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!--
  2. // (c) Copyright Microsoft Corporation.
  3. // This source is subject to the Microsoft Public License (Ms-PL).
  4. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
  5. // All other rights reserved.
  6. -->
  7. <Styles xmlns="https://github.com/avaloniaui"
  8. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  9. xmlns:sys="clr-namespace:System;assembly=netstandard">
  10. <Style Selector="CalendarDatePicker">
  11. <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
  12. <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
  13. <Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
  14. <Setter Property="Padding" Value="4"/>
  15. <Setter Property="Template">
  16. <ControlTemplate>
  17. <Grid ColumnDefinitions="*,Auto">
  18. <Grid.Styles>
  19. <Style Selector="Button.CalendarDropDown">
  20. <Setter Property="Template">
  21. <ControlTemplate>
  22. <Grid Height="18"
  23. Width="19"
  24. HorizontalAlignment="Center"
  25. VerticalAlignment="Center"
  26. Margin="0"
  27. Background="{DynamicResource ThemeControlLowBrush}"
  28. ColumnDefinitions="*,*,*,*"
  29. RowDefinitions="23*,19*,19*,19*"
  30. ClipToBounds="False">
  31. <Border Name="Highlight"
  32. Margin="-1"
  33. Grid.ColumnSpan="4"
  34. Grid.Row="0"
  35. Grid.RowSpan="4"
  36. BorderThickness="1"
  37. BorderBrush="{DynamicResource HighlightBrush}" />
  38. <Border Name="Background"
  39. Margin="0,-1,0,0"
  40. Grid.ColumnSpan="4"
  41. Grid.Row="1"
  42. Grid.RowSpan="3"
  43. BorderThickness="1"
  44. BorderBrush="{DynamicResource ThemeBorderHighBrush}"
  45. CornerRadius=".5" />
  46. <Rectangle Grid.ColumnSpan="4"
  47. Grid.RowSpan="1"
  48. StrokeThickness="1"
  49. Stroke="{DynamicResource ThemeBorderHighBrush}"
  50. Fill="{DynamicResource ThemeAccentBrush}">
  51. </Rectangle>
  52. <TextBlock Margin="0,-1,0,0"
  53. VerticalAlignment="Center"
  54. HorizontalAlignment="Center"
  55. Grid.Column="0"
  56. Grid.Row="1"
  57. Grid.ColumnSpan="4"
  58. Grid.RowSpan="3"
  59. FontSize="{DynamicResource FontSizeSmall}"
  60. Foreground="{DynamicResource ThemeBorderHighBrush}"
  61. Text="{Binding Source={x:Static sys:DateTime.Today}, Path=Day}"/>
  62. <Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{DynamicResource ThemeControlLowBrush}" StrokeThickness="0" Grid.ColumnSpan="4" Width="3" Height="3"/>
  63. </Grid>
  64. </ControlTemplate>
  65. </Setter>
  66. </Style>
  67. <Style Selector="Button.CalendarDropDown /template/ Border#Highlight">
  68. <Setter Property="IsVisible" Value="False"/>
  69. </Style>
  70. <Style Selector="Button.CalendarDropDown:pressed /template/ Border#Highlight">
  71. <Setter Property="IsVisible" Value="True"/>
  72. </Style>
  73. <Style Selector="Button.CalendarDropDown:pointerover /template/ Border#Background">
  74. <Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/>
  75. </Style>
  76. </Grid.Styles>
  77. <TextBox Name="PART_TextBox"
  78. Background="{TemplateBinding Background}"
  79. BorderBrush="{TemplateBinding BorderBrush}"
  80. BorderThickness="{TemplateBinding BorderThickness}"
  81. Padding="{TemplateBinding Padding}"
  82. Watermark="{TemplateBinding Watermark}"
  83. UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
  84. DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
  85. Grid.Column="0"/>
  86. <Button Name="PART_Button"
  87. Grid.Column="1"
  88. Width="20"
  89. Classes="CalendarDropDown"
  90. Foreground="{TemplateBinding Foreground}"
  91. Background="Transparent"
  92. BorderThickness="0"
  93. Margin="2,0,2,0"
  94. Padding="0"
  95. ClipToBounds="False"
  96. Focusable="False"/>
  97. <Popup Name="PART_Popup"
  98. PlacementTarget="{TemplateBinding}"
  99. StaysOpen="False">
  100. <Calendar Name="PART_Calendar"
  101. FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
  102. IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}"/>
  103. </Popup>
  104. </Grid>
  105. </ControlTemplate>
  106. </Setter>
  107. </Style>
  108. <Style Selector="CalendarDatePicker:focus /template/ TextBox#PART_TextBox">
  109. <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/>
  110. </Style>
  111. </Styles>