ComboBoxStyle.xaml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  4. <!--<Style x:Key="FocusVisual">
  5. <Setter Property="Control.Template">
  6. <Setter.Value>
  7. <ControlTemplate>
  8. <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
  9. </ControlTemplate>
  10. </Setter.Value>
  11. </Setter>
  12. </Style>
  13. <SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF"/>
  14. <Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
  15. <Setter Property="OverridesDefaultStyle" Value="true"/>
  16. <Setter Property="AllowDrop" Value="true"/>
  17. <Setter Property="MinWidth" Value="0"/>
  18. <Setter Property="MinHeight" Value="0"/>
  19. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  20. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  21. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  22. <Setter Property="Template">
  23. <Setter.Value>
  24. <ControlTemplate TargetType="{x:Type TextBox}">
  25. <ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
  26. </ControlTemplate>
  27. </Setter.Value>
  28. </Setter>
  29. </Style>
  30. <LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0">
  31. <GradientStop Color="#FFF0F0F0" Offset="0.0"/>
  32. <GradientStop Color="#FFE5E5E5" Offset="1.0"/>
  33. </LinearGradientBrush>
  34. <SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC"/>
  35. <SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060"/>
  36. <SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="#FFFFFFFF"/>
  37. <SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#FFABADB3"/>
  38. <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/>
  39. <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/>
  40. <LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0">
  41. <GradientStop Color="#FFECF4FC" Offset="0.0"/>
  42. <GradientStop Color="#FFDCECFC" Offset="1.0"/>
  43. </LinearGradientBrush>
  44. <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/>
  45. <SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/>
  46. <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/>
  47. <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/>
  48. <LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0">
  49. <GradientStop Color="#FFEBF4FC" Offset="0.0"/>
  50. <GradientStop Color="#FFDCECFC" Offset="1.0"/>
  51. </LinearGradientBrush>
  52. <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/>
  53. <LinearGradientBrush x:Key="ComboBox.Pressed.Background" EndPoint="0,1" StartPoint="0,0">
  54. <GradientStop Color="#FFDAECFC" Offset="0.0"/>
  55. <GradientStop Color="#FFC4E0FC" Offset="1.0"/>
  56. </LinearGradientBrush>
  57. <SolidColorBrush x:Key="ComboBox.Pressed.Border" Color="#FF569DE5"/>
  58. <SolidColorBrush x:Key="ComboBox.Pressed.Glyph" Color="#FF000000"/>
  59. <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Background" Color="#FFFFFFFF"/>
  60. <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Border" Color="#FF569DE5"/>
  61. <LinearGradientBrush x:Key="ComboBox.Pressed.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0">
  62. <GradientStop Color="#FFDAEBFC" Offset="0.0"/>
  63. <GradientStop Color="#FFC4E0FC" Offset="1.0"/>
  64. </LinearGradientBrush>
  65. <SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Border" Color="#FF569DE5"/>
  66. <SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#FFF0F0F0"/>
  67. <SolidColorBrush x:Key="ComboBox.Disabled.Border" Color="#FFD9D9D9"/>
  68. <SolidColorBrush x:Key="ComboBox.Disabled.Glyph" Color="#FFBFBFBF"/>
  69. <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Background" Color="#FFFFFFFF"/>
  70. <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Border" Color="#FFBFBFBF"/>
  71. <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Background" Color="Transparent"/>
  72. <SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Border" Color="Transparent"/>
  73. <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
  74. <Setter Property="OverridesDefaultStyle" Value="true"/>
  75. <Setter Property="IsTabStop" Value="false"/>
  76. <Setter Property="Focusable" Value="false"/>
  77. <Setter Property="ClickMode" Value="Press"/>
  78. <Setter Property="Template">
  79. <Setter.Value>
  80. <ControlTemplate TargetType="{x:Type ToggleButton}">
  81. <Border x:Name="templateRoot" Background="Transparent" CornerRadius="2" BorderBrush="{StaticResource ComboBox.Static.Border}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
  82. <Border x:Name="splitBorder" BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="true" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
  83. <Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z" Fill="{StaticResource ComboBox.Static.Glyph}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/>
  84. </Border>
  85. </Border>
  86. <ControlTemplate.Triggers>
  87. <MultiDataTrigger>
  88. <MultiDataTrigger.Conditions>
  89. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
  90. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="false"/>
  91. <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="false"/>
  92. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/>
  93. </MultiDataTrigger.Conditions>
  94. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Background}"/>
  95. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Border}"/>
  96. <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Background}"/>
  97. <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Border}"/>
  98. </MultiDataTrigger>
  99. <Trigger Property="IsMouseOver" Value="true">
  100. <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.MouseOver.Glyph}"/>
  101. </Trigger>
  102. <MultiDataTrigger>
  103. <MultiDataTrigger.Conditions>
  104. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  105. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
  106. </MultiDataTrigger.Conditions>
  107. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/>
  108. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/>
  109. </MultiDataTrigger>
  110. <MultiDataTrigger>
  111. <MultiDataTrigger.Conditions>
  112. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  113. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
  114. </MultiDataTrigger.Conditions>
  115. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Background}"/>
  116. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Border}"/>
  117. <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Background}"/>
  118. <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Border}"/>
  119. </MultiDataTrigger>
  120. <Trigger Property="IsPressed" Value="true">
  121. <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Pressed.Glyph}"/>
  122. </Trigger>
  123. <MultiDataTrigger>
  124. <MultiDataTrigger.Conditions>
  125. <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
  126. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
  127. </MultiDataTrigger.Conditions>
  128. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Background}"/>
  129. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Border}"/>
  130. </MultiDataTrigger>
  131. <MultiDataTrigger>
  132. <MultiDataTrigger.Conditions>
  133. <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
  134. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
  135. </MultiDataTrigger.Conditions>
  136. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Background}"/>
  137. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Border}"/>
  138. <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Background}"/>
  139. <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Border}"/>
  140. </MultiDataTrigger>
  141. <Trigger Property="IsEnabled" Value="false">
  142. <Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Disabled.Glyph}"/>
  143. </Trigger>
  144. <MultiDataTrigger>
  145. <MultiDataTrigger.Conditions>
  146. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  147. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
  148. </MultiDataTrigger.Conditions>
  149. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Background}"/>
  150. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Border}"/>
  151. </MultiDataTrigger>
  152. <MultiDataTrigger>
  153. <MultiDataTrigger.Conditions>
  154. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  155. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
  156. </MultiDataTrigger.Conditions>
  157. <Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Background}"/>
  158. <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Border}"/>
  159. <Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Background}"/>
  160. <Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Border}"/>
  161. </MultiDataTrigger>
  162. </ControlTemplate.Triggers>
  163. </ControlTemplate>
  164. </Setter.Value>
  165. </Setter>
  166. </Style>
  167. <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
  168. <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
  169. <Grid.ColumnDefinitions>
  170. <ColumnDefinition Width="*"/>
  171. <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
  172. </Grid.ColumnDefinitions>
  173. <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
  174. <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
  175. <Border x:Name="dropDownBorder" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" CornerRadius="2" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1">
  176. <ScrollViewer x:Name="DropDownScrollViewer">
  177. <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
  178. <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
  179. <Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
  180. </Canvas>
  181. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  182. </Grid>
  183. </ScrollViewer>
  184. </Border>
  185. </theme:SystemDropShadowChrome>
  186. </Popup>
  187. <ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
  188. <Border x:Name="border" Background="{StaticResource TextBox.Static.Background}" Margin="{TemplateBinding BorderThickness}">
  189. <TextBox x:Name="PART_EditableTextBox" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Margin="{TemplateBinding Padding}" Style="{StaticResource ComboBoxEditableTextBox}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
  190. </Border>
  191. </Grid>
  192. <ControlTemplate.Triggers>
  193. <Trigger Property="IsEnabled" Value="false">
  194. <Setter Property="Opacity" TargetName="border" Value="0.56"/>
  195. </Trigger>
  196. <Trigger Property="IsKeyboardFocusWithin" Value="true">
  197. <Setter Property="Foreground" Value="Black"/>
  198. </Trigger>
  199. <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
  200. <Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
  201. <Setter Property="Color" TargetName="shadow" Value="#71000000"/>
  202. </Trigger>
  203. <Trigger Property="HasItems" Value="false">
  204. <Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
  205. </Trigger>
  206. <MultiTrigger>
  207. <MultiTrigger.Conditions>
  208. <Condition Property="IsGrouping" Value="true"/>
  209. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
  210. </MultiTrigger.Conditions>
  211. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  212. </MultiTrigger>
  213. <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
  214. <Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
  215. <Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
  216. </Trigger>
  217. </ControlTemplate.Triggers>
  218. </ControlTemplate>
  219. <ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
  220. <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
  221. <Grid.ColumnDefinitions>
  222. <ColumnDefinition Width="*"/>
  223. <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
  224. </Grid.ColumnDefinitions>
  225. <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
  226. <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
  227. <Border x:Name="dropDownBorder" CornerRadius="2" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1">
  228. <ScrollViewer x:Name="DropDownScrollViewer">
  229. <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
  230. <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
  231. <Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
  232. </Canvas>
  233. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  234. </Grid>
  235. </ScrollViewer>
  236. </Border>
  237. </theme:SystemDropShadowChrome>
  238. </Popup>
  239. <ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
  240. <ContentPresenter x:Name="contentPresenter" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  241. </Grid>
  242. <ControlTemplate.Triggers>
  243. <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
  244. <Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
  245. <Setter Property="Color" TargetName="shadow" Value="#71000000"/>
  246. </Trigger>
  247. <Trigger Property="HasItems" Value="false">
  248. <Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
  249. </Trigger>
  250. <MultiTrigger>
  251. <MultiTrigger.Conditions>
  252. <Condition Property="IsGrouping" Value="true"/>
  253. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
  254. </MultiTrigger.Conditions>
  255. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  256. </MultiTrigger>
  257. <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
  258. <Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
  259. <Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
  260. </Trigger>
  261. </ControlTemplate.Triggers>
  262. </ControlTemplate>-->
  263. <Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}">
  264. <Setter Property="Background" Value="White"/>
  265. <Setter Property="ItemContainerStyle">
  266. <Setter.Value>
  267. <!--CmbItem-->
  268. <Style TargetType="ComboBoxItem">
  269. <Setter Property="MinHeight" Value="32"></Setter>
  270. <Setter Property="MinWidth" Value="60"></Setter>
  271. <Setter Property="FontSize" Value="12"></Setter>
  272. <Setter Property="Template">
  273. <Setter.Value>
  274. <ControlTemplate TargetType="ComboBoxItem">
  275. <Border Name="Back" Background="Transparent">
  276. <ContentPresenter x:Name="contentPresenter" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>
  277. </Border>
  278. <ControlTemplate.Triggers>
  279. <Trigger Property="IsMouseOver" Value="True">
  280. <Setter TargetName="Back" Property="Background" Value="LightGray"></Setter>
  281. </Trigger>
  282. <Trigger Property="IsHighlighted" Value="True">
  283. <Setter TargetName="Back" Property="Background" Value="LightGray"></Setter>
  284. </Trigger>
  285. </ControlTemplate.Triggers>
  286. </ControlTemplate>
  287. </Setter.Value>
  288. </Setter>
  289. </Style>
  290. </Setter.Value>
  291. </Setter>
  292. <Setter Property="Template">
  293. <Setter.Value>
  294. <ControlTemplate TargetType="{x:Type ComboBox}">
  295. <Border x:Name="comboBoxBorder" BorderThickness="1" BorderBrush="#AFAFAF" Background="{TemplateBinding Background}" >
  296. <Grid >
  297. <Grid.ColumnDefinitions>
  298. <ColumnDefinition Width="3*"/>
  299. <ColumnDefinition Width="*"/>
  300. </Grid.ColumnDefinitions>
  301. <Grid Grid.Column="0" x:Name="grid">
  302. <ToggleButton
  303. Width="{Binding ElementName=grid,Path=ActualWidth}"
  304. Height="{Binding ElementName=grid, Path=ActualHeight}"
  305. Content="{TemplateBinding Text}" VerticalAlignment="Center"
  306. HorizontalAlignment="Left" Margin="5,0,0,0"
  307. BorderThickness="0"
  308. Foreground="{TemplateBinding Foreground}"
  309. Background="{TemplateBinding Background}"
  310. IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"
  311. >
  312. <ToggleButton.Style >
  313. <Style TargetType="ToggleButton">
  314. <Setter Property="Background" Value="White"/>
  315. <Setter Property="Template">
  316. <Setter.Value>
  317. <ControlTemplate TargetType="ToggleButton">
  318. <Border Background="{TemplateBinding Background}" BorderThickness="0" >
  319. <TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" Margin="4 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
  320. </Border>
  321. </ControlTemplate>
  322. </Setter.Value>
  323. </Setter>
  324. <Style.Triggers>
  325. <Trigger Property="IsMouseOver" Value="True">
  326. <Setter Property="Background" Value="White"/>
  327. </Trigger>
  328. <Trigger Property="IsMouseOver" Value="False">
  329. <Setter Property="Background" Value="White"/>
  330. </Trigger>
  331. </Style.Triggers>
  332. </Style>
  333. </ToggleButton.Style>
  334. </ToggleButton>
  335. </Grid>
  336. <Grid Grid.Column="1" >
  337. <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  338. Foreground="{TemplateBinding Foreground}"
  339. ClickMode="Press">
  340. <ToggleButton.Style>
  341. <Style TargetType="ToggleButton">
  342. <Setter Property="Background" Value="White"/>
  343. <Setter Property="Template">
  344. <Setter.Value>
  345. <ControlTemplate TargetType="ToggleButton">
  346. <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
  347. <Grid>
  348. <Viewbox x:Name="ArrowVbx" Width="12" Height="12">
  349. <Path Fill="#666666" Data="M9.95941,0.800781 L11.1998,1.88866 L5.9998,7.20078 L0.799805,1.88866 L2.0402,0.800781 L5.9998,4.8452 L9.95941,0.800781 Z"/>
  350. <Viewbox.RenderTransform>
  351. <TransformGroup>
  352. <ScaleTransform/>
  353. <SkewTransform/>
  354. <RotateTransform CenterX="6" CenterY="4" Angle="0"/>
  355. <TranslateTransform/>
  356. </TransformGroup>
  357. </Viewbox.RenderTransform>
  358. </Viewbox>
  359. </Grid>
  360. </Border>
  361. <ControlTemplate.Triggers>
  362. <EventTrigger RoutedEvent="Checked">
  363. <BeginStoryboard>
  364. <Storyboard >
  365. <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ArrowVbx" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
  366. <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  367. <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="180"/>
  368. </DoubleAnimationUsingKeyFrames>
  369. </Storyboard>
  370. </BeginStoryboard>
  371. </EventTrigger>
  372. <EventTrigger RoutedEvent="Unchecked">
  373. <BeginStoryboard>
  374. <Storyboard >
  375. <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ArrowVbx" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
  376. <EasingDoubleKeyFrame KeyTime="00:00:00" Value="180"/>
  377. <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
  378. </DoubleAnimationUsingKeyFrames>
  379. </Storyboard>
  380. </BeginStoryboard>
  381. </EventTrigger>
  382. </ControlTemplate.Triggers>
  383. </ControlTemplate>
  384. </Setter.Value>
  385. </Setter>
  386. </Style>
  387. </ToggleButton.Style>
  388. </ToggleButton>
  389. </Grid>
  390. <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
  391. <Border CornerRadius="1" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
  392. <Border.Effect>
  393. <DropShadowEffect Color="Black" BlurRadius="4" ShadowDepth="0" Opacity="0.5"/>
  394. </Border.Effect>
  395. <ScrollViewer Margin="4,6,4,6" Style="{DynamicResource ScrollViewerStyle}" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
  396. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="White"/>
  397. </ScrollViewer>
  398. </Border>
  399. </Popup>
  400. </Grid>
  401. </Border>
  402. <ControlTemplate.Triggers>
  403. <Trigger Property="IsMouseOver" Value="True">
  404. <Setter TargetName="comboBoxBorder" Property="BorderBrush" Value="#388EF7"></Setter>
  405. <Setter Property="Effect">
  406. <Setter.Value>
  407. <DropShadowEffect Color="#00BFFF" ShadowDepth="0" BlurRadius="5" Opacity="0.5"/>
  408. </Setter.Value>
  409. </Setter>
  410. </Trigger>
  411. <Trigger Property="IsEnabled" Value="False">
  412. <Setter Property="Opacity" Value="0.5" />
  413. </Trigger>
  414. </ControlTemplate.Triggers>
  415. </ControlTemplate>
  416. </Setter.Value>
  417. </Setter>
  418. </Style>
  419. </ResourceDictionary>