终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RecComboBox.xaml 11 KiB

vor 2 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <!--#region ComboBox 样式-->
  3. <!-- ComBoBox项选中背景色 -->
  4. <SolidColorBrush x:Key="ComboBoxSelectdBackground" Color="#AA3ba7f2" />
  5. <!-- ComBoBox项鼠标经过背景色 -->
  6. <SolidColorBrush x:Key="ComboBoxMouseOverBackground" Color="#553ba7f2" />
  7. <!-- ComBoBox项选中前景色 -->
  8. <SolidColorBrush x:Key="ComboBoxSelectedForeground" Color="#DDD" />
  9. <!-- ComBoBox项鼠标经过前景色 -->
  10. <SolidColorBrush x:Key="ComboBoxMouseOverForegrond" Color="#DDD" />
  11. <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
  12. <Grid Height="25" HorizontalAlignment="Stretch">
  13. <Grid.ColumnDefinitions>
  14. <ColumnDefinition Width="*" />
  15. <ColumnDefinition Width="30" />
  16. </Grid.ColumnDefinitions>
  17. <Border
  18. Grid.ColumnSpan="2"
  19. Background="White"
  20. Opacity="0" />
  21. <TextBlock
  22. Grid.Column="1"
  23. Margin="0,0,5,0"
  24. HorizontalAlignment="Right"
  25. VerticalAlignment="Center"
  26. FontFamily="../Fonts/#iconfont"
  27. FontSize="14"
  28. Foreground="#ff23CACA"
  29. Text="&#xe64d;" />
  30. <!--<Path
  31. x:Name="Arrow"
  32. Grid.Column="1"
  33. HorizontalAlignment="Center"
  34. VerticalAlignment="Center"
  35. Data="M 0 0 6 6 12 0 Z"
  36. Fill="#aa20FDFA"
  37. Stretch="None">
  38. <Path.Effect>
  39. <DropShadowEffect
  40. BlurRadius="10"
  41. Direction="90"
  42. Opacity="1"
  43. RenderingBias="Quality"
  44. ShadowDepth="0"
  45. Color="#aa20FDFA" />
  46. </Path.Effect>
  47. </Path>-->
  48. </Grid>
  49. <!--<ControlTemplate.Triggers>
  50. <Trigger Property="IsChecked" Value="true">
  51. <Setter TargetName="Arrow" Property="RenderTransform">
  52. <Setter.Value>
  53. <RotateTransform Angle="180" CenterX="6" CenterY="3" />
  54. </Setter.Value>
  55. </Setter>
  56. <Setter TargetName="Arrow" Property="Margin" Value="0,0,0,2" />
  57. </Trigger>
  58. </ControlTemplate.Triggers>-->
  59. </ControlTemplate>
  60. <Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
  61. <Setter Property="BorderThickness" Value="0" />
  62. <Setter Property="ItemContainerStyle">
  63. <Setter.Value>
  64. <Style TargetType="ComboBoxItem">
  65. <Setter Property="Height" Value="25" />
  66. <Setter Property="Template">
  67. <Setter.Value>
  68. <ControlTemplate TargetType="{x:Type ComboBoxItem}">
  69. <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
  70. <Border x:Name="_borderbg" Background="Transparent" />
  71. <TextBlock
  72. x:Name="_txt"
  73. Margin="5,0,3,0"
  74. HorizontalAlignment="Left"
  75. VerticalAlignment="Center"
  76. Foreground="#DDD"
  77. Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
  78. <Border
  79. x:Name="_border"
  80. Background="#103153"
  81. Opacity="0" />
  82. </Grid>
  83. <ControlTemplate.Triggers>
  84. <Trigger Property="IsSelected" Value="true">
  85. <Setter TargetName="_txt" Property="Foreground" Value="{StaticResource ComboBoxSelectedForeground}" />
  86. <Setter TargetName="_borderbg" Property="Background" Value="{StaticResource ComboBoxSelectdBackground}" />
  87. </Trigger>
  88. <MultiTrigger>
  89. <MultiTrigger.Conditions>
  90. <Condition Property="IsSelected" Value="false" />
  91. <Condition Property="IsMouseOver" Value="true" />
  92. </MultiTrigger.Conditions>
  93. <Setter TargetName="_borderbg" Property="Background" Value="{StaticResource ComboBoxMouseOverBackground}" />
  94. <Setter TargetName="_txt" Property="Foreground" Value="{StaticResource ComboBoxMouseOverForegrond}" />
  95. </MultiTrigger>
  96. </ControlTemplate.Triggers>
  97. </ControlTemplate>
  98. </Setter.Value>
  99. </Setter>
  100. </Style>
  101. </Setter.Value>
  102. </Setter>
  103. <Setter Property="Template">
  104. <Setter.Value>
  105. <ControlTemplate TargetType="{x:Type ComboBox}">
  106. <Grid>
  107. <Grid.ColumnDefinitions>
  108. <ColumnDefinition Width="0.7*" />
  109. <ColumnDefinition Width="0.3*" MaxWidth="30" />
  110. </Grid.ColumnDefinitions>
  111. <Border
  112. x:Name="_prybr"
  113. Grid.Column="0"
  114. Grid.ColumnSpan="2"
  115. BorderBrush="{TemplateBinding BorderBrush}"
  116. BorderThickness="{TemplateBinding BorderThickness}"
  117. CornerRadius="0" />
  118. <ContentPresenter
  119. x:Name="ContentSite"
  120. Margin="3,3,0,3"
  121. HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
  122. VerticalAlignment="Center"
  123. Content="{TemplateBinding SelectionBoxItem}"
  124. ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  125. ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
  126. IsHitTestVisible="False" />
  127. <!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen -->
  128. <ToggleButton
  129. x:Name="ToggleButton"
  130. Grid.Column="0"
  131. Grid.ColumnSpan="2"
  132. ClickMode="Press"
  133. Focusable="false"
  134. IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  135. Template="{StaticResource ComboBoxToggleButton}" />
  136. <!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 -->
  137. <TextBox
  138. x:Name="PART_EditableTextBox"
  139. Margin="2,0,0,0"
  140. VerticalAlignment="Center"
  141. Background="Transparent"
  142. BorderThickness="0"
  143. CaretBrush="{TemplateBinding Foreground}"
  144. Focusable="True"
  145. Foreground="{TemplateBinding Foreground}"
  146. IsReadOnly="{TemplateBinding IsReadOnly}"
  147. Visibility="Hidden" />
  148. <!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen -->
  149. <Popup
  150. x:Name="Popup"
  151. AllowsTransparency="True"
  152. Focusable="False"
  153. IsOpen="{TemplateBinding IsDropDownOpen}"
  154. Placement="Bottom"
  155. PopupAnimation="Slide">
  156. <Grid
  157. x:Name="DropDown"
  158. MinWidth="{TemplateBinding ActualWidth}"
  159. MaxHeight="150"
  160. SnapsToDevicePixels="True">
  161. <Border
  162. x:Name="DropDownBorder"
  163. BorderBrush="#3ba7f2"
  164. BorderThickness="0" />
  165. <ScrollViewer
  166. Margin="1"
  167. CanContentScroll="True"
  168. HorizontalScrollBarVisibility="Auto"
  169. SnapsToDevicePixels="True"
  170. VerticalScrollBarVisibility="Auto">
  171. <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
  172. <!-- 一下可以设置列表背景色 -->
  173. <StackPanel
  174. Background="#103153"
  175. IsItemsHost="True"
  176. KeyboardNavigation.DirectionalNavigation="Contained" />
  177. </ScrollViewer>
  178. </Grid>
  179. </Popup>
  180. </Grid>
  181. <ControlTemplate.Triggers>
  182. <Trigger Property="IsEditable" Value="true">
  183. <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
  184. </Trigger>
  185. <Trigger Property="IsMouseOver" Value="True">
  186. <Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" />
  187. <!--<Setter Property="Background" Value="#553ba7f2" TargetName="_prybr"/>-->
  188. </Trigger>
  189. <Trigger Property="IsEnabled" Value="False">
  190. <Setter TargetName="ContentSite" Property="Opacity" Value="0.6" />
  191. </Trigger>
  192. </ControlTemplate.Triggers>
  193. </ControlTemplate>
  194. </Setter.Value>
  195. </Setter>
  196. </Style>
  197. <!--#endregion-->
  198. </ResourceDictionary>