TimePicker.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <UserControl x:Class="NEIntelligentControl2.Views.Basic.TimePicker"
  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:NEIntelligentControl2.Views.Basic"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="120">
  9. <UserControl.Resources>
  10. <local:DateTimeConver x:Key="dtc"/>
  11. <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
  12. <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
  13. <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
  14. <Style x:Key="TextBoxStyleDateTime" TargetType="{x:Type TextBox}">
  15. <Setter Property="Background" Value="WhiteSmoke"/>
  16. <Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
  17. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  18. <Setter Property="BorderThickness" Value="1"/>
  19. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  20. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  21. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  22. <Setter Property="AllowDrop" Value="true"/>
  23. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  24. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type TextBox}">
  28. <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" MinHeight="23">
  29. <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" VerticalAlignment="Center"/>
  30. </Border>
  31. <ControlTemplate.Triggers>
  32. <Trigger Property="IsEnabled" Value="false">
  33. <Setter Property="Opacity" TargetName="border" Value="0.56"/>
  34. </Trigger>
  35. <Trigger Property="IsMouseOver" Value="true">
  36. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
  37. </Trigger>
  38. <Trigger Property="IsKeyboardFocused" Value="true">
  39. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
  40. </Trigger>
  41. </ControlTemplate.Triggers>
  42. </ControlTemplate>
  43. </Setter.Value>
  44. </Setter>
  45. <Style.Triggers>
  46. <MultiTrigger>
  47. <MultiTrigger.Conditions>
  48. <Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
  49. <Condition Property="IsSelectionActive" Value="false"/>
  50. </MultiTrigger.Conditions>
  51. <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
  52. </MultiTrigger>
  53. </Style.Triggers>
  54. </Style>
  55. <Style TargetType="{x:Type ScrollBar}">
  56. <Setter Property="Background" Value="#77F0F8FF"/>
  57. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
  58. <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
  59. <!--滚动条宽度-->
  60. <Setter Property="Width" Value="8"/>
  61. <Setter Property="MinWidth" Value="6"/>
  62. <Setter Property="Template">
  63. <Setter.Value>
  64. <ControlTemplate TargetType="{x:Type ScrollBar}">
  65. <!--滚动条背景色-->
  66. <Grid x:Name="Bg" Background="#77DDDDDD" SnapsToDevicePixels="true" Width="8">
  67. <Grid.RowDefinitions>
  68. <RowDefinition />
  69. </Grid.RowDefinitions>
  70. <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">
  71. <Track.DecreaseRepeatButton>
  72. <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
  73. </Track.DecreaseRepeatButton>
  74. <Track.IncreaseRepeatButton>
  75. <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
  76. </Track.IncreaseRepeatButton>
  77. <Track.Thumb>
  78. <Thumb Style="{StaticResource ScrollBarThumb}"/>
  79. </Track.Thumb>
  80. </Track>
  81. </Grid>
  82. <ControlTemplate.Triggers>
  83. <Trigger Property="IsEnabled" Value="false">
  84. <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
  85. </Trigger>
  86. </ControlTemplate.Triggers>
  87. </ControlTemplate>
  88. </Setter.Value>
  89. </Setter>
  90. <Style.Triggers>
  91. <Trigger Property="Orientation" Value="Horizontal">
  92. <Setter Property="Width" Value="Auto"/>
  93. <Setter Property="MinWidth" Value="0"/>
  94. <Setter Property="Height" Value="6"/>
  95. <Setter Property="MinHeight" Value="6"/>
  96. <Setter Property="Background" Value="#77F0F8FF"/>
  97. <Setter Property="Template">
  98. <Setter.Value>
  99. <ControlTemplate TargetType="{x:Type ScrollBar}">
  100. <Grid x:Name="Bg" Background="#77DDDDDD" SnapsToDevicePixels="true">
  101. <Grid.ColumnDefinitions>
  102. <ColumnDefinition />
  103. </Grid.ColumnDefinitions>
  104. <Track x:Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}">
  105. <Track.DecreaseRepeatButton>
  106. <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
  107. </Track.DecreaseRepeatButton>
  108. <Track.IncreaseRepeatButton>
  109. <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
  110. </Track.IncreaseRepeatButton>
  111. <Track.Thumb>
  112. <Thumb Style="{StaticResource ScrollBarThumb}" />
  113. </Track.Thumb>
  114. </Track>
  115. </Grid>
  116. <ControlTemplate.Triggers>
  117. <Trigger Property="IsEnabled" Value="false">
  118. <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
  119. </Trigger>
  120. </ControlTemplate.Triggers>
  121. </ControlTemplate>
  122. </Setter.Value>
  123. </Setter>
  124. </Trigger>
  125. </Style.Triggers>
  126. </Style>
  127. </UserControl.Resources>
  128. <Grid x:Name="_gd">
  129. <TextBox x:Name="_tb" Style="{DynamicResource TextBoxStyleDateTime}" PreviewMouseLeftButtonDown="TextBox_PreviewMouseLeftButtonDown" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}, Path=SelectedDateTime, Converter={StaticResource dtc}}" LostFocus="TextBox_LostFocus"/>
  130. <Popup x:Name="_popup" AllowsTransparency="True" PopupAnimation="Fade" Focusable="True" PlacementTarget="{Binding ElementName=_gd}" Placement="Bottom">
  131. <Border Background="WhiteSmoke" CornerRadius="7" Margin="5" Height="207" Width="310" x:Name="_bd" Focusable="True">
  132. <Border.Effect>
  133. <DropShadowEffect ShadowDepth="0" RenderingBias="Quality"/>
  134. </Border.Effect>
  135. <Grid Margin="5">
  136. <Grid.ColumnDefinitions>
  137. <ColumnDefinition Width="Auto"/>
  138. <ColumnDefinition/>
  139. <ColumnDefinition/>
  140. </Grid.ColumnDefinitions>
  141. <Grid.RowDefinitions>
  142. <RowDefinition Height="Auto"/>
  143. <RowDefinition/>
  144. <RowDefinition Height="Auto"/>
  145. </Grid.RowDefinitions>
  146. <Calendar SelectedDatesChanged="Calendar_SelectedDatesChanged" Grid.RowSpan="2" Focusable="False"/>
  147. <TextBlock Grid.Column="1" Text="时" HorizontalAlignment="Center"/>
  148. <TextBlock Grid.Column="2" Text="分" HorizontalAlignment="Center"/>
  149. <ListBox x:Name="_lbhour" Grid.Row="1" Grid.Column="1" Margin="3,0,0,3" SelectionChanged="ListBox_SelectionChanged" Tag="hour"/>
  150. <ListBox x:Name="_lbminute" Grid.Row="1" Grid.Column="2" Margin="0,0,0,3" SelectionChanged="ListBox_SelectionChanged" Tag="minute"/>
  151. <StackPanel Grid.Row="2" Grid.ColumnSpan="10" HorizontalAlignment="Right" Orientation="Horizontal">
  152. <Button Content="确 定" Padding="12,3" Margin="3" Click="Button_Click" Tag="ok" IsDefault="True" Style="{StaticResource ConfirmButtonStyle}"/>
  153. <Button Content="取 消" Padding="12,3" Margin="0,3" Click="Button_Click" Tag="cancel" Style="{StaticResource CancelButtonStyle}"/>
  154. </StackPanel>
  155. </Grid>
  156. </Border>
  157. </Popup>
  158. </Grid>
  159. </UserControl>