ComboBox.xaml 31 KB

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