ComboBox.xaml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  4. <Style x:Key="ComboBoxFocusVisual">
  5. <Setter Property="Control.Template">
  6. <Setter.Value>
  7. <ControlTemplate>
  8. <Rectangle Margin="4,4,21,4" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
  9. </ControlTemplate>
  10. </Setter.Value>
  11. </Setter>
  12. </Style>
  13. <Geometry x:Key="DownArrowGeometry">M 0 0 L 5 5 L 10 0 Z</Geometry>
  14. <SolidColorBrush x:Key="ToggleButton_BD" Color="Black"/>
  15. <LinearGradientBrush x:Key="ToggleButton_BG" EndPoint="0.5,1" StartPoint="0.5,0">
  16. <GradientStop Color="#FF597EAA" Offset="0"/>
  17. <GradientStop Color="#FFA1BAD8" Offset="1"/>
  18. </LinearGradientBrush>
  19. <SolidColorBrush x:Key="ToggleButton_InnerHighlight" Color="#FF809CBE"/>
  20. <SolidColorBrush x:Key="ToggleButton_InnerShadow" Color="#FF334459"/>
  21. <LinearGradientBrush x:Key="ToggleButton_BG_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
  22. <GradientStop Color="#FF234887" Offset="0"/>
  23. <GradientStop Color="#FF6590CA" Offset="1"/>
  24. </LinearGradientBrush>
  25. <SolidColorBrush x:Key="ComboBox_DropDown_BG" Color="#FF2A6AB6"/>
  26. <SolidColorBrush x:Key="ComboBox_DropDown_BD" Color="#FF0A2B58"/>
  27. <SolidColorBrush x:Key="ComboBox_BG" Color="White"/>
  28. <SolidColorBrush x:Key="ComboBox_BD" Color="#FF999999"/>
  29. <SolidColorBrush x:Key="ComboBox_BD_InnerShadow" Color="#FF404040"/>
  30. <SolidColorBrush x:Key="ComboBox_BD_InnerHighlight" Color="#FFD2D2D2"/>
  31. <SolidColorBrush x:Key="ComboBox_BG_Unable" Color="#FFDBDBDB"/>
  32. <SolidColorBrush x:Key="ComboBox_BD_Unable" Color="Gray"/>
  33. <SolidColorBrush x:Key="ComboBox_BD_InnerShadow_Unable" Color="#FF838383"/>
  34. <SolidColorBrush x:Key="ToggleButton_Login_BD" Color="#FF092B58"/>
  35. <LinearGradientBrush x:Key="ToggleButton_Login_BG" EndPoint="0.5,1" StartPoint="0.5,0">
  36. <GradientStop Color="#FF0C4277" Offset="0"/>
  37. <GradientStop Color="#FF1373C8" Offset="1"/>
  38. </LinearGradientBrush>
  39. <SolidColorBrush x:Key="ToggleButton_Login_InnerHighlight" Color="#FF416C95"/>
  40. <SolidColorBrush x:Key="ToggleButton_Login_InnerShadow" Color="#FF093861"/>
  41. <SolidColorBrush x:Key="ToggleButton_Login_BD_MouseOver" Color="#FF05162c"/>
  42. <LinearGradientBrush x:Key="ToggleButton_Login_BG_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
  43. <GradientStop Color="#FF115b9b" Offset="0"/>
  44. <GradientStop Color="#FF1b96de" Offset="1"/>
  45. </LinearGradientBrush>
  46. <SolidColorBrush x:Key="ToggleButton_Login_InnerHighlight_MouseOver" Color="#FF457fb1"/>
  47. <SolidColorBrush x:Key="ToggleButton_Login_InnerShadow_MouseOver" Color="#FF0d496d"/>
  48. <SolidColorBrush x:Key="ToggleButton_ArrowBG" Color="White"/>
  49. <SolidColorBrush x:Key="ToggleButton_BD_Unable" Color="#FF868686"/>
  50. <LinearGradientBrush x:Key="ToggleButton_BG_Unable" EndPoint="0.5,1" StartPoint="0.5,0">
  51. <GradientStop Color="#FFB1B1B1" Offset="0"/>
  52. <GradientStop Color="#FFDADADA" Offset="1"/>
  53. </LinearGradientBrush>
  54. <SolidColorBrush x:Key="ToggleButton_InnerHighlight_Unable" Color="#FFD8D8D8"/>
  55. <SolidColorBrush x:Key="ToggleButton_InnerShadow_Unable" Color="#FF6C6C6C"/>
  56. <SolidColorBrush x:Key="ComboBox_DropDown_Login_BG" Color="#FF2A6AB6"/>
  57. <SolidColorBrush x:Key="ComboBox_DropDown_Login_BD" Color="#FF0A2B58"/>
  58. <SolidColorBrush x:Key="ComboBox_Login_BG" Color="#FF006CB8"/>
  59. <SolidColorBrush x:Key="ComboBox_Login_BD" Color="#FF092b58"/>
  60. <!-- Toggle Button Style -->
  61. <Style x:Key="ComboBoxReadonlyToggleButton" TargetType="{x:Type ToggleButton}">
  62. <Setter Property="SnapsToDevicePixels" Value="True"/>
  63. <Setter Property="OverridesDefaultStyle" Value="true"/>
  64. <Setter Property="BorderBrush" Value="{DynamicResource ToggleButton_BD}"/>
  65. <Setter Property="Background" Value="{DynamicResource ToggleButton_BG}"/>
  66. <Setter Property="BorderThickness" Value="1"/>
  67. <Setter Property="IsTabStop" Value="false"/>
  68. <Setter Property="Focusable" Value="false"/>
  69. <Setter Property="ClickMode" Value="Press"/>
  70. <Setter Property="Template">
  71. <Setter.Value>
  72. <ControlTemplate TargetType="{x:Type ToggleButton}">
  73. <Grid Background="#00FFFFFF">
  74. <Grid.ColumnDefinitions>
  75. <ColumnDefinition/>
  76. <ColumnDefinition Width="25"/>
  77. </Grid.ColumnDefinitions>
  78. <Border x:Name="BG" Grid.Column="1" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Cursor="Hand"/>
  79. <Border x:Name="InnerBD_Highlight" Grid.Column="1" BorderThickness="1,1,0,0" BorderBrush="{DynamicResource ToggleButton_InnerHighlight}">
  80. <Border x:Name="InnerBD_Shadow" BorderThickness="0,0,1,1" BorderBrush="{DynamicResource ToggleButton_InnerShadow}"/>
  81. </Border>
  82. <Path x:Name="Arrow" Grid.Column="1" Data="{StaticResource DownArrowGeometry}" Fill="{DynamicResource ToggleButton_ArrowBG}" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand">
  83. <Path.Effect>
  84. <DropShadowEffect BlurRadius="0" ShadowDepth="1"/>
  85. </Path.Effect>
  86. </Path>
  87. </Grid>
  88. <ControlTemplate.Triggers>
  89. <Trigger Property="IsMouseOver" Value="true">
  90. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_BG_MouseOver}"/>
  91. </Trigger>
  92. <Trigger Property="IsEnabled" Value="false">
  93. <Setter Property="BorderBrush" TargetName="BG" Value="{DynamicResource ToggleButton_BD_Unable}"/>
  94. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_BG_Unable}"/>
  95. <Setter Property="Fill" TargetName="Arrow" Value="#FF999999"/>
  96. <Setter Property="Effect" TargetName="Arrow">
  97. <Setter.Value>
  98. <DropShadowEffect BlurRadius="0" ShadowDepth="1" Opacity="0"/>
  99. </Setter.Value>
  100. </Setter>
  101. <Setter Property="BorderBrush" TargetName="InnerBD_Shadow" Value="{DynamicResource ToggleButton_InnerShadow_Unable}"/>
  102. <Setter Property="BorderBrush" TargetName="InnerBD_Highlight" Value="{DynamicResource ToggleButton_InnerHighlight_Unable}"/>
  103. </Trigger>
  104. </ControlTemplate.Triggers>
  105. </ControlTemplate>
  106. </Setter.Value>
  107. </Setter>
  108. </Style>
  109. <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
  110. <Setter Property="BorderBrush" Value="{DynamicResource ToggleButton_BD}"/>
  111. <Setter Property="Background" Value="{DynamicResource ToggleButton_BG}"/>
  112. <Setter Property="BorderThickness" Value="1"/>
  113. <Setter Property="OverridesDefaultStyle" Value="true"/>
  114. <Setter Property="IsTabStop" Value="false"/>
  115. <Setter Property="Focusable" Value="false"/>
  116. <Setter Property="ClickMode" Value="Press"/>
  117. <Setter Property="Template">
  118. <Setter.Value>
  119. <ControlTemplate TargetType="{x:Type ToggleButton}">
  120. <Border x:Name="BG" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Cursor="Hand">
  121. <Grid>
  122. <Border x:Name="InnerBD_Highlight" BorderThickness="1.5,1.5,0,0" BorderBrush="{DynamicResource ToggleButton_InnerHighlight}">
  123. <Border x:Name="InnerBD_Shadow" BorderThickness="0,0,1.5,1.5" BorderBrush="{DynamicResource ToggleButton_InnerShadow}"/>
  124. </Border>
  125. <Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="{DynamicResource ToggleButton_ArrowBG}" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand">
  126. <Path.Effect>
  127. <DropShadowEffect BlurRadius="0" ShadowDepth="1"/>
  128. </Path.Effect>
  129. </Path>
  130. </Grid>
  131. </Border>
  132. <ControlTemplate.Triggers>
  133. <Trigger Property="IsMouseOver" Value="true">
  134. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_BG_MouseOver}"/>
  135. </Trigger>
  136. <Trigger Property="IsEnabled" Value="false">
  137. <Setter Property="BorderBrush" TargetName="BG" Value="{DynamicResource ToggleButton_BD_Unable}"/>
  138. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_BG_Unable}"/>
  139. <Setter Property="Fill" TargetName="Arrow" Value="#FF999999"/>
  140. <Setter Property="Effect" TargetName="Arrow">
  141. <Setter.Value>
  142. <DropShadowEffect BlurRadius="0" ShadowDepth="1" Opacity="0"/>
  143. </Setter.Value>
  144. </Setter>
  145. <Setter Property="BorderBrush" TargetName="InnerBD_Shadow" Value="{DynamicResource ToggleButton_InnerShadow_Unable}"/>
  146. <Setter Property="BorderBrush" TargetName="InnerBD_Highlight" Value="{DynamicResource ToggleButton_InnerHighlight_Unable}"/>
  147. </Trigger>
  148. </ControlTemplate.Triggers>
  149. </ControlTemplate>
  150. </Setter.Value>
  151. </Setter>
  152. </Style>
  153. <Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
  154. <Setter Property="OverridesDefaultStyle" Value="true"/>
  155. <Setter Property="AllowDrop" Value="true"/>
  156. <Setter Property="MinWidth" Value="0"/>
  157. <Setter Property="MinHeight" Value="0"/>
  158. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  159. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  160. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  161. <Setter Property="Template">
  162. <Setter.Value>
  163. <ControlTemplate TargetType="{x:Type TextBox}">
  164. <ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
  165. </ControlTemplate>
  166. </Setter.Value>
  167. </Setter>
  168. </Style>
  169. <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
  170. <Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
  171. <Border BorderBrush="Gray" BorderThickness="0,0,1,1">
  172. <Grid x:Name="Placement" SnapsToDevicePixels="true">
  173. <Grid.ColumnDefinitions>
  174. <ColumnDefinition Width="*"/>
  175. <ColumnDefinition Width="25"/>
  176. </Grid.ColumnDefinitions>
  177. <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
  178. <Border x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
  179. <ScrollViewer x:Name="DropDownScrollViewer">
  180. <Grid RenderOptions.ClearTypeHint="Enabled">
  181. <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
  182. <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
  183. </Canvas>
  184. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  185. </Grid>
  186. </ScrollViewer>
  187. </Border>
  188. </Popup>
  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. <ToggleButton Grid.Column="1" Margin="1,1,0,0" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
  191. </Grid>
  192. </Border>
  193. </Border>
  194. <ControlTemplate.Triggers>
  195. <Trigger Property="IsKeyboardFocusWithin" Value="true">
  196. <Setter Property="Foreground" Value="Black"/>
  197. </Trigger>
  198. <Trigger Property="IsDropDownOpen" Value="true">
  199. </Trigger>
  200. <Trigger Property="HasItems" Value="false">
  201. <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
  202. </Trigger>
  203. <Trigger Property="IsEnabled" Value="false">
  204. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  205. <Setter Property="Background" Value="#FFF4F4F4"/>
  206. </Trigger>
  207. <Trigger Property="IsGrouping" Value="true">
  208. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  209. </Trigger>
  210. <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
  211. </Trigger>
  212. <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
  213. <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
  214. <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
  215. </Trigger>
  216. </ControlTemplate.Triggers>
  217. </ControlTemplate>
  218. <!-- ComboBox Style -->
  219. <Style TargetType="{x:Type ComboBox}">
  220. <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
  221. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
  222. <Setter Property="Background" Value="{DynamicResource ComboBox_BG}"/>
  223. <Setter Property="BorderBrush" Value="{DynamicResource ComboBox_BD}"/>
  224. <Setter Property="FontFamily" Value="Arial"/>
  225. <Setter Property="BorderThickness" Value="1"/>
  226. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  227. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  228. <Setter Property="Padding" Value="4,3"/>
  229. <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  230. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  231. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  232. <Setter Property="Template">
  233. <Setter.Value>
  234. <ControlTemplate TargetType="{x:Type ComboBox}">
  235. <Grid x:Name="MainGrid" SnapsToDevicePixels="true">
  236. <Grid.ColumnDefinitions>
  237. <ColumnDefinition Width="*"/>
  238. <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
  239. </Grid.ColumnDefinitions>
  240. <Popup x:Name="PART_Popup" Grid.ColumnSpan="2" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" Focusable="False" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="2" >
  241. <Border x:Name="DropDownBorder" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
  242. <ScrollViewer x:Name="DropDownScrollViewer" Margin="0,5">
  243. <Grid RenderOptions.ClearTypeHint="Enabled">
  244. <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
  245. <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
  246. </Canvas>
  247. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  248. </Grid>
  249. </ScrollViewer>
  250. </Border>
  251. <Popup.Effect>
  252. <DropShadowEffect Color="#71000000"/>
  253. </Popup.Effect>
  254. </Popup>
  255. <Border x:Name="Bd" Grid.ColumnSpan="2" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
  256. <Border x:Name="InnerBD_Shadow" BorderBrush="{DynamicResource ComboBox_BD_InnerShadow}" BorderThickness="1,1,0,0">
  257. <Border x:Name="InnerBD_Highlight" BorderBrush="{DynamicResource ComboBox_BD_InnerHighlight}" BorderThickness="0,0,1,1">
  258. </Border>
  259. </Border>
  260. </Border>
  261. <ToggleButton x:Name="ToggleButton" Style="{StaticResource ComboBoxReadonlyToggleButton}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Cursor="Hand" Margin="2"/>
  262. <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="4,3,20,3" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
  263. </Grid>
  264. <ControlTemplate.Triggers>
  265. <Trigger Property="HasItems" Value="false">
  266. <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
  267. </Trigger>
  268. <Trigger Property="IsEnabled" Value="false">
  269. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  270. <Setter Property="Background" TargetName="Bd" Value="{DynamicResource ComboBox_BG_Unable}"/>
  271. <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource ComboBox_BD_Unable}"/>
  272. <Setter Property="BorderBrush" TargetName="InnerBD_Shadow" Value="{DynamicResource ComboBox_BD_InnerShadow_Unable}"/>
  273. </Trigger>
  274. <Trigger Property="IsGrouping" Value="true">
  275. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  276. </Trigger>
  277. <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
  278. <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
  279. <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
  280. </Trigger>
  281. </ControlTemplate.Triggers>
  282. </ControlTemplate>
  283. </Setter.Value>
  284. </Setter>
  285. <Style.Triggers>
  286. <Trigger Property="IsEditable" Value="true">
  287. <Setter Property="BorderBrush" Value="Black"/>
  288. <Setter Property="Background" Value="White"/>
  289. <Setter Property="IsTabStop" Value="false"/>
  290. <Setter Property="Padding" Value="3"/>
  291. <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
  292. </Trigger>
  293. </Style.Triggers>
  294. </Style>
  295. <!-- Login ComboBox Style -->
  296. <Style x:Key="ComboBoxReadonlyToggleButton_Login" TargetType="{x:Type ToggleButton}">
  297. <Setter Property="SnapsToDevicePixels" Value="True"/>
  298. <Setter Property="OverridesDefaultStyle" Value="true"/>
  299. <Setter Property="BorderBrush" Value="{DynamicResource ToggleButton_Login_BD}"/>
  300. <Setter Property="Background" Value="{DynamicResource ToggleButton_Login_BG}"/>
  301. <Setter Property="BorderThickness" Value="1"/>
  302. <Setter Property="IsTabStop" Value="false"/>
  303. <Setter Property="Focusable" Value="false"/>
  304. <Setter Property="ClickMode" Value="Press"/>
  305. <Setter Property="Template">
  306. <Setter.Value>
  307. <ControlTemplate TargetType="{x:Type ToggleButton}">
  308. <Border x:Name="BG" CornerRadius="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Cursor="Hand">
  309. <Grid>
  310. <Border x:Name="InnerBD_Highlight" CornerRadius="3" BorderThickness="1.5,1.5,0,0" BorderBrush="{DynamicResource ToggleButton_Login_InnerHighlight}">
  311. <Border x:Name="InnerBD_Shadow" CornerRadius="3" BorderThickness="0,0,1.5,1.5" BorderBrush="{DynamicResource ToggleButton_Login_InnerShadow}"/>
  312. </Border>
  313. <Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="{DynamicResource ToggleButton_ArrowBG}" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand">
  314. <Path.Effect>
  315. <DropShadowEffect BlurRadius="0" ShadowDepth="1"/>
  316. </Path.Effect>
  317. </Path>
  318. </Grid>
  319. </Border>
  320. <ControlTemplate.Triggers>
  321. <Trigger Property="IsMouseOver" Value="true">
  322. <Setter Property="BorderBrush" TargetName="BG" Value="{DynamicResource ToggleButton_Login_BD_MouseOver}"/>
  323. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_Login_BG_MouseOver}"/>
  324. <Setter Property="BorderBrush" TargetName="InnerBD_Shadow" Value="{DynamicResource ToggleButton_Login_InnerShadow_MouseOver}"/>
  325. <Setter Property="BorderBrush" TargetName="InnerBD_Highlight" Value="{DynamicResource ToggleButton_Login_InnerHighlight_MouseOver}"/>
  326. </Trigger>
  327. <Trigger Property="IsEnabled" Value="false">
  328. <Setter Property="BorderBrush" TargetName="BG" Value="{DynamicResource ToggleButton_BD_Unable}"/>
  329. <Setter Property="Background" TargetName="BG" Value="{DynamicResource ToggleButton_BG_Unable}"/>
  330. <Setter Property="Fill" TargetName="Arrow" Value="#FF999999"/>
  331. <Setter Property="Effect" TargetName="Arrow">
  332. <Setter.Value>
  333. <DropShadowEffect BlurRadius="0" ShadowDepth="1" Opacity="0"/>
  334. </Setter.Value>
  335. </Setter>
  336. <Setter Property="BorderBrush" TargetName="InnerBD_Shadow" Value="{DynamicResource ToggleButton_InnerShadow_Unable}"/>
  337. <Setter Property="BorderBrush" TargetName="InnerBD_Highlight" Value="{DynamicResource ToggleButton_InnerHighlight_Unable}"/>
  338. </Trigger>
  339. </ControlTemplate.Triggers>
  340. </ControlTemplate>
  341. </Setter.Value>
  342. </Setter>
  343. </Style>
  344. <Style x:Key="Login_ComboBox" TargetType="{x:Type ComboBox}">
  345. <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
  346. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  347. <Setter Property="Background" Value="{DynamicResource ComboBox_Login_BG}"/>
  348. <Setter Property="BorderBrush" Value="{DynamicResource ComboBox_Login_BD}"/>
  349. <Setter Property="FontFamily" Value="Arial"/>
  350. <Setter Property="BorderThickness" Value="2"/>
  351. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  352. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  353. <Setter Property="Padding" Value="4,3"/>
  354. <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  355. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  356. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  357. <Setter Property="Template">
  358. <Setter.Value>
  359. <ControlTemplate TargetType="{x:Type ComboBox}">
  360. <Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5" SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
  361. <Grid x:Name="MainGrid" SnapsToDevicePixels="true">
  362. <Grid.ColumnDefinitions>
  363. <ColumnDefinition Width="*"/>
  364. <ColumnDefinition Width="30"/>
  365. </Grid.ColumnDefinitions>
  366. <Popup x:Name="PART_Popup" Grid.ColumnSpan="2" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" Focusable="False" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="2" >
  367. <Border x:Name="DropDownBorder" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" BorderBrush="{DynamicResource ComboBox_DropDown_Login_BD}" BorderThickness="1" Background="{DynamicResource ComboBox_DropDown_Login_BG}">
  368. <ScrollViewer x:Name="DropDownScrollViewer" Margin="0,5">
  369. <Grid RenderOptions.ClearTypeHint="Enabled">
  370. <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
  371. <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
  372. </Canvas>
  373. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  374. </Grid>
  375. </ScrollViewer>
  376. </Border>
  377. <Popup.Effect>
  378. <DropShadowEffect Color="#71000000"/>
  379. </Popup.Effect>
  380. </Popup>
  381. <ToggleButton Margin="1" Grid.Column="1" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxReadonlyToggleButton_Login}"/>
  382. <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
  383. </Grid>
  384. </Border>
  385. <ControlTemplate.Triggers>
  386. <Trigger Property="HasItems" Value="false">
  387. <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
  388. </Trigger>
  389. <Trigger Property="IsEnabled" Value="false">
  390. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  391. <Setter Property="Background" TargetName="Bd" Value="#FFDBDBDB"/>
  392. <Setter Property="BorderBrush" TargetName="Bd" Value="Gray"/>
  393. </Trigger>
  394. <Trigger Property="IsGrouping" Value="true">
  395. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  396. </Trigger>
  397. <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
  398. <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
  399. <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
  400. </Trigger>
  401. </ControlTemplate.Triggers>
  402. </ControlTemplate>
  403. </Setter.Value>
  404. </Setter>
  405. <Style.Triggers>
  406. <Trigger Property="IsEditable" Value="true">
  407. <Setter Property="BorderBrush" Value="Black"/>
  408. <Setter Property="Background" Value="White"/>
  409. <Setter Property="IsTabStop" Value="false"/>
  410. <Setter Property="Padding" Value="3"/>
  411. <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
  412. </Trigger>
  413. </Style.Triggers>
  414. </Style>
  415. </ResourceDictionary>