MyDateTimePicker.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <UserControl x:Class="BlankApp1.Controls.MyDateTimePicker"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:BlankApp1.Controls"
  7. xmlns:convt="clr-namespace:BlankApp1.Controls.Convert"
  8. mc:Ignorable="d"
  9. Height="25" Width="145" Margin="2">
  10. <UserControl.Resources>
  11. <convt:InverseBooleanConverter x:Key="inverseBoolConvert"/>
  12. </UserControl.Resources>
  13. <Grid x:Name="GridMain">
  14. <Grid.ColumnDefinitions>
  15. <ColumnDefinition Width="*"/>
  16. <ColumnDefinition Width="25"/>
  17. </Grid.ColumnDefinitions>
  18. <Border x:Name="BorderMain" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="Gray" Margin="0"/>
  19. <TextBox x:Name="TextDateTime" Tag="请选择时间">
  20. <TextBox.Style>
  21. <Style TargetType="TextBox">
  22. <Setter Property="Margin" Value="3"/>
  23. <Setter Property="Template">
  24. <Setter.Value>
  25. <ControlTemplate TargetType="TextBox">
  26. <TextBlock Margin="2"
  27. VerticalAlignment="Center"
  28. FontSize="11"
  29. Text="{TemplateBinding TextBox.Text}"
  30. />
  31. </ControlTemplate>
  32. </Setter.Value>
  33. </Setter>
  34. <Style.Triggers>
  35. <MultiTrigger>
  36. <MultiTrigger.Conditions>
  37. <Condition Property="Text" Value=""/>
  38. </MultiTrigger.Conditions>
  39. <Setter Property="Template">
  40. <Setter.Value>
  41. <ControlTemplate>
  42. <Border BorderThickness="0" Margin="0" Padding="5,2,5,2">
  43. <TextBlock x:Name="MainTextBlock"
  44. Text="{TemplateBinding TextBox.Tag}"
  45. Width="{TemplateBinding TextBox.ActualWidth}"
  46. Foreground="Gray"
  47. FontSize="11"
  48. VerticalAlignment="Center"
  49. HorizontalAlignment="Left"/>
  50. </Border>
  51. </ControlTemplate>
  52. </Setter.Value>
  53. </Setter>
  54. </MultiTrigger>
  55. </Style.Triggers>
  56. </Style>
  57. </TextBox.Style>
  58. </TextBox>
  59. <ToggleButton x:Name="BtnPop" Grid.Column="1" ClickMode="Release" IsThreeState="False" IsEnabled="{Binding Path=IsOpen, ElementName=PopDateTime,Converter={StaticResource inverseBoolConvert}}">
  60. <ToggleButton.Template>
  61. <ControlTemplate>
  62. <Grid Background="Transparent" x:Name="GridIco">
  63. <TextBlock x:Name="TextIco" FontSize="15" Text="🕛" VerticalAlignment="Center" Foreground="Black"/>
  64. </Grid>
  65. <ControlTemplate.Triggers>
  66. <Trigger Property="IsMouseOver" Value="True">
  67. <Setter TargetName="GridIco" Property="Background" Value="#008CD7"></Setter>
  68. <Setter TargetName="TextIco" Property="Foreground" Value="white"></Setter>
  69. </Trigger>
  70. </ControlTemplate.Triggers>
  71. </ControlTemplate>
  72. </ToggleButton.Template>
  73. </ToggleButton>
  74. <Popup x:Name="PopDateTime" PopupAnimation="Slide" AllowsTransparency="True" Placement="Bottom" StaysOpen="False" IsOpen="{Binding ElementName=BtnPop,Path=IsChecked,Mode=TwoWay}">
  75. <Grid Background="White">
  76. <Grid.RowDefinitions>
  77. <RowDefinition/>
  78. <RowDefinition/>
  79. <RowDefinition/>
  80. </Grid.RowDefinitions>
  81. <Calendar x:Name="MyCalendar" Grid.Row="0" BorderThickness="0" SelectionMode="SingleDate" PreviewMouseUp="MyCalendar_PreviewMouseUp"/>
  82. <Grid Grid.Row="1" HorizontalAlignment="Center" Margin="6">
  83. <Grid.ColumnDefinitions>
  84. <ColumnDefinition/>
  85. <ColumnDefinition Width="22"/>
  86. <ColumnDefinition/>
  87. <ColumnDefinition Width="22"/>
  88. <ColumnDefinition/>
  89. <ColumnDefinition Width="22"/>
  90. <ColumnDefinition/>
  91. <ColumnDefinition/>
  92. </Grid.ColumnDefinitions>
  93. <Border Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" BorderThickness="1" BorderBrush="Transparent"/>
  94. <TextBlock Grid.Column="0" Text="时间:" Margin="5,2,5,2" VerticalAlignment="Center"/>
  95. <Button x:Name="Btnhh" Grid.Column="1" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnhh_Click"/>
  96. <TextBlock Grid.Column="2" Text=":" Margin="1,0,1,0" VerticalAlignment="Center"/>
  97. <Button x:Name="Btnmm" Grid.Column="3" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnmm_Click"/>
  98. <TextBlock Grid.Column="4" Text=":" Margin="1,0,1,0" VerticalAlignment="Center"/>
  99. <Button x:Name="Btnss" Grid.Column="5" Content="00" Background="Transparent" BorderThickness="0" VerticalAlignment="Center" Click="Btnss_Click"/>
  100. <Popup x:Name="Pop24" PopupAnimation="Slide" AllowsTransparency="True" PlacementTarget="{Binding ElementName=Btnhh}" Placement="Bottom" StaysOpen="False" IsOpen="False">
  101. <Grid>
  102. <!--四行六列,共24个-->
  103. <Grid.ColumnDefinitions>
  104. <ColumnDefinition/>
  105. <ColumnDefinition/>
  106. <ColumnDefinition/>
  107. <ColumnDefinition/>
  108. <ColumnDefinition/>
  109. <ColumnDefinition/>
  110. </Grid.ColumnDefinitions>
  111. <Grid.RowDefinitions>
  112. <RowDefinition/>
  113. <RowDefinition/>
  114. <RowDefinition/>
  115. <RowDefinition/>
  116. </Grid.RowDefinitions>
  117. <Grid.Resources>
  118. <Style TargetType="Button">
  119. <!--<Setter Property="Background" Value="#008CD7"/>-->
  120. <Setter Property="Background" Value="#eee"/>
  121. <Setter Property="BorderThickness" Value="0"/>
  122. <Setter Property="Height" Value="25"/>
  123. <Setter Property="Width" Value="25"/>
  124. <Setter Property="Margin" Value="1"/>
  125. <EventSetter Event="Click" Handler="Button_Click"/>
  126. </Style>
  127. </Grid.Resources>
  128. <Border Background="White" Grid.ColumnSpan="6" Grid.RowSpan="4"/>
  129. <Button Content="00" Grid.Row="0" Grid.Column="0"/>
  130. <Button Content="01" Grid.Row="0" Grid.Column="1"/>
  131. <Button Content="02" Grid.Row="0" Grid.Column="2"/>
  132. <Button Content="03" Grid.Row="0" Grid.Column="3"/>
  133. <Button Content="04" Grid.Row="0" Grid.Column="4"/>
  134. <Button Content="05" Grid.Row="0" Grid.Column="5"/>
  135. <Button Content="06" Grid.Row="1" Grid.Column="0"/>
  136. <Button Content="07" Grid.Row="1" Grid.Column="1"/>
  137. <Button Content="08" Grid.Row="1" Grid.Column="2"/>
  138. <Button Content="09" Grid.Row="1" Grid.Column="3"/>
  139. <Button Content="10" Grid.Row="1" Grid.Column="4"/>
  140. <Button Content="11" Grid.Row="1" Grid.Column="5"/>
  141. <Button Content="12" Grid.Row="2" Grid.Column="0"/>
  142. <Button Content="13" Grid.Row="2" Grid.Column="1"/>
  143. <Button Content="14" Grid.Row="2" Grid.Column="2"/>
  144. <Button Content="15" Grid.Row="2" Grid.Column="3"/>
  145. <Button Content="16" Grid.Row="2" Grid.Column="4"/>
  146. <Button Content="17" Grid.Row="2" Grid.Column="5"/>
  147. <Button Content="18" Grid.Row="3" Grid.Column="0"/>
  148. <Button Content="19" Grid.Row="3" Grid.Column="1"/>
  149. <Button Content="20" Grid.Row="3" Grid.Column="2"/>
  150. <Button Content="21" Grid.Row="3" Grid.Column="3"/>
  151. <Button Content="22" Grid.Row="3" Grid.Column="4"/>
  152. <Button Content="23" Grid.Row="3" Grid.Column="5"/>
  153. </Grid>
  154. </Popup>
  155. <Popup x:Name="Pop60" PopupAnimation="Slide" AllowsTransparency="True" PlacementTarget="{Binding ElementName=Btnhh}" Placement="Bottom" StaysOpen="False" IsOpen="False">
  156. <Grid>
  157. <!--十行六列,共60个-->
  158. <Grid.ColumnDefinitions>
  159. <ColumnDefinition/>
  160. <ColumnDefinition/>
  161. <ColumnDefinition/>
  162. <ColumnDefinition/>
  163. <ColumnDefinition/>
  164. <ColumnDefinition/>
  165. </Grid.ColumnDefinitions>
  166. <Grid.RowDefinitions>
  167. <RowDefinition/>
  168. <RowDefinition/>
  169. <RowDefinition/>
  170. <RowDefinition/>
  171. <RowDefinition/>
  172. <RowDefinition/>
  173. <RowDefinition/>
  174. <RowDefinition/>
  175. <RowDefinition/>
  176. <RowDefinition/>
  177. </Grid.RowDefinitions>
  178. <Grid.Resources>
  179. <Style TargetType="Button">
  180. <!--<Setter Property="Background" Value="#008CD7"/>-->
  181. <Setter Property="Background" Value="#eee"/>
  182. <Setter Property="BorderThickness" Value="0"/>
  183. <Setter Property="Height" Value="25"/>
  184. <Setter Property="Width" Value="25"/>
  185. <Setter Property="Margin" Value="1"/>
  186. <EventSetter Event="Click" Handler="Button_Click_1"/>
  187. </Style>
  188. </Grid.Resources>
  189. <Border Background="White" Grid.ColumnSpan="6" Grid.RowSpan="10"/>
  190. <Button Content="00" Grid.Row="0" Grid.Column="0"/>
  191. <Button Content="01" Grid.Row="0" Grid.Column="1"/>
  192. <Button Content="02" Grid.Row="0" Grid.Column="2"/>
  193. <Button Content="03" Grid.Row="0" Grid.Column="3"/>
  194. <Button Content="04" Grid.Row="0" Grid.Column="4"/>
  195. <Button Content="05" Grid.Row="0" Grid.Column="5"/>
  196. <Button Content="06" Grid.Row="1" Grid.Column="0"/>
  197. <Button Content="07" Grid.Row="1" Grid.Column="1"/>
  198. <Button Content="08" Grid.Row="1" Grid.Column="2"/>
  199. <Button Content="09" Grid.Row="1" Grid.Column="3"/>
  200. <Button Content="10" Grid.Row="1" Grid.Column="4"/>
  201. <Button Content="11" Grid.Row="1" Grid.Column="5"/>
  202. <Button Content="12" Grid.Row="2" Grid.Column="0"/>
  203. <Button Content="13" Grid.Row="2" Grid.Column="1"/>
  204. <Button Content="14" Grid.Row="2" Grid.Column="2"/>
  205. <Button Content="15" Grid.Row="2" Grid.Column="3"/>
  206. <Button Content="16" Grid.Row="2" Grid.Column="4"/>
  207. <Button Content="17" Grid.Row="2" Grid.Column="5"/>
  208. <Button Content="18" Grid.Row="3" Grid.Column="0"/>
  209. <Button Content="19" Grid.Row="3" Grid.Column="1"/>
  210. <Button Content="20" Grid.Row="3" Grid.Column="2"/>
  211. <Button Content="21" Grid.Row="3" Grid.Column="3"/>
  212. <Button Content="22" Grid.Row="3" Grid.Column="4"/>
  213. <Button Content="23" Grid.Row="3" Grid.Column="5"/>
  214. <Button Content="24" Grid.Row="4" Grid.Column="0"/>
  215. <Button Content="25" Grid.Row="4" Grid.Column="1"/>
  216. <Button Content="26" Grid.Row="4" Grid.Column="2"/>
  217. <Button Content="27" Grid.Row="4" Grid.Column="3"/>
  218. <Button Content="28" Grid.Row="4" Grid.Column="4"/>
  219. <Button Content="29" Grid.Row="4" Grid.Column="5"/>
  220. <Button Content="30" Grid.Row="5" Grid.Column="0"/>
  221. <Button Content="31" Grid.Row="5" Grid.Column="1"/>
  222. <Button Content="32" Grid.Row="5" Grid.Column="2"/>
  223. <Button Content="33" Grid.Row="5" Grid.Column="3"/>
  224. <Button Content="34" Grid.Row="5" Grid.Column="4"/>
  225. <Button Content="35" Grid.Row="5" Grid.Column="5"/>
  226. <Button Content="36" Grid.Row="6" Grid.Column="0"/>
  227. <Button Content="37" Grid.Row="6" Grid.Column="1"/>
  228. <Button Content="38" Grid.Row="6" Grid.Column="2"/>
  229. <Button Content="39" Grid.Row="6" Grid.Column="3"/>
  230. <Button Content="40" Grid.Row="6" Grid.Column="4"/>
  231. <Button Content="41" Grid.Row="6" Grid.Column="5"/>
  232. <Button Content="42" Grid.Row="7" Grid.Column="0"/>
  233. <Button Content="43" Grid.Row="7" Grid.Column="1"/>
  234. <Button Content="44" Grid.Row="7" Grid.Column="2"/>
  235. <Button Content="45" Grid.Row="7" Grid.Column="3"/>
  236. <Button Content="46" Grid.Row="7" Grid.Column="4"/>
  237. <Button Content="47" Grid.Row="7" Grid.Column="5"/>
  238. <Button Content="48" Grid.Row="8" Grid.Column="0"/>
  239. <Button Content="49" Grid.Row="8" Grid.Column="1"/>
  240. <Button Content="50" Grid.Row="8" Grid.Column="2"/>
  241. <Button Content="51" Grid.Row="8" Grid.Column="3"/>
  242. <Button Content="52" Grid.Row="8" Grid.Column="4"/>
  243. <Button Content="53" Grid.Row="8" Grid.Column="5"/>
  244. <Button Content="54" Grid.Row="9" Grid.Column="0"/>
  245. <Button Content="55" Grid.Row="9" Grid.Column="1"/>
  246. <Button Content="56" Grid.Row="9" Grid.Column="2"/>
  247. <Button Content="57" Grid.Row="9" Grid.Column="3"/>
  248. <Button Content="58" Grid.Row="9" Grid.Column="4"/>
  249. <Button Content="59" Grid.Row="9" Grid.Column="5"/>
  250. </Grid>
  251. </Popup>
  252. </Grid>
  253. <Grid Grid.Row="2" Margin="1">
  254. <Grid.ColumnDefinitions>
  255. <ColumnDefinition/>
  256. <ColumnDefinition/>
  257. </Grid.ColumnDefinitions>
  258. <Button x:Name="BtnNow" Grid.Column="0" Content="当前" Background="#6BE6C1" BorderBrush="#6BE6C1" Click="BtnNow_Click"/>
  259. <Button x:Name="BtnSave" Grid.Column="1" Content="确定" Click="BtnSave_Click" />
  260. </Grid>
  261. </Grid>
  262. </Popup>
  263. </Grid>
  264. </UserControl>