You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

519 lines
35 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl"
  4. xmlns:converter="clr-namespace:BPA.UIControl.Converters">
  5. <ResourceDictionary.MergedDictionaries>
  6. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Textbox.xaml" />
  7. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/ScrollViewer.xaml" />
  8. </ResourceDictionary.MergedDictionaries>
  9. <converter:ComboBoxPopupWidthConverter x:Key="ComboBoxPopupWidth" />
  10. <Style x:Key="RubyerComboBoxItem" TargetType="{x:Type ComboBoxItem}">
  11. <Setter Property="SnapsToDevicePixels" Value="True" />
  12. <Setter Property="Padding" Value="{Binding Path=(bpa:ItemsControlHelper.ItemPadding), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  13. <Setter Property="Margin" Value="{Binding Path=(bpa:ItemsControlHelper.ItemMargin), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  14. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
  15. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
  16. <Setter Property="Background" Value="Transparent" />
  17. <Setter Property="BorderBrush" Value="Transparent" />
  18. <Setter Property="BorderThickness" Value="0" />
  19. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  20. <Setter Property="Template">
  21. <Setter.Value>
  22. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  23. <Grid>
  24. <bpa:ControlMask x:Name="mask"
  25. Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=ItemsControl}}"
  26. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=ItemsControl}}"
  27. IsActive="{TemplateBinding IsSelected}"
  28. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=ItemsControl}}" />
  29. <Border x:Name="Bd"
  30. Padding="{TemplateBinding Padding}"
  31. Background="{TemplateBinding Background}"
  32. BorderBrush="{TemplateBinding BorderBrush}"
  33. BorderThickness="{TemplateBinding BorderThickness}"
  34. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  35. <DockPanel>
  36. <CheckBox x:Name="selectCheckBox"
  37. Margin="0 0 5 0"
  38. IsChecked="{Binding Path=(bpa:ComboBoxHelper.IsSelected), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  39. Visibility="Collapsed" />
  40. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  41. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  42. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  43. </DockPanel>
  44. </Border>
  45. </Grid>
  46. <ControlTemplate.Triggers>
  47. <Trigger Property="IsEnabled" Value="False">
  48. <Setter TargetName="Bd" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  49. </Trigger>
  50. <DataTrigger Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource AncestorType=ComboBox}}" Value="True">
  51. <Setter TargetName="selectCheckBox" Property="Visibility" Value="Visible" />
  52. <Setter TargetName="mask" Property="Visibility" Value="Collapsed" />
  53. </DataTrigger>
  54. </ControlTemplate.Triggers>
  55. </ControlTemplate>
  56. </Setter.Value>
  57. </Setter>
  58. </Style>
  59. <Style x:Key="RubyerComboBoxEditableTextBox"
  60. BasedOn="{StaticResource RubyerTextBox}"
  61. TargetType="{x:Type TextBox}">
  62. <Setter Property="AllowDrop" Value="True" />
  63. <Setter Property="MinWidth" Value="0" />
  64. <Setter Property="MinHeight" Value="0" />
  65. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  66. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
  67. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  68. <Setter Property="BorderThickness" Value="0" />
  69. <Setter Property="Background" Value="Transparent" />
  70. <Setter Property="BorderBrush" Value="Transparent" />
  71. </Style>
  72. <Style x:Key="RubyerComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
  73. <Setter Property="OverridesDefaultStyle" Value="True" />
  74. <Setter Property="IsTabStop" Value="False" />
  75. <Setter Property="Focusable" Value="False" />
  76. <Setter Property="ClickMode" Value="Press" />
  77. <Setter Property="Background" Value="{DynamicResource DefaultBackground}" />
  78. <Setter Property="SnapsToDevicePixels" Value="True" />
  79. <Setter Property="Template">
  80. <Setter.Value>
  81. <ControlTemplate TargetType="{x:Type ToggleButton}">
  82. <Grid>
  83. <Border x:Name="effectBorder"
  84. Background="{TemplateBinding Background}"
  85. BorderBrush="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}"
  86. BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource AncestorType=ComboBox}}"
  87. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=ComboBox}}"
  88. Opacity="0">
  89. <Border.Effect>
  90. <DropShadowEffect x:Name="shadowEffect"
  91. BlurRadius="2"
  92. Direction="0"
  93. ShadowDepth="0"
  94. Color="{Binding BorderBrush.Color, ElementName=effectBorder}" />
  95. </Border.Effect>
  96. </Border>
  97. <Border x:Name="templateRoot"
  98. Padding="{TemplateBinding Margin}"
  99. Background="{TemplateBinding Background}"
  100. BorderBrush="{TemplateBinding BorderBrush}"
  101. BorderThickness="{TemplateBinding BorderThickness}"
  102. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
  103. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  104. <DockPanel>
  105. <bpa:Icon x:Name="arrow"
  106. Grid.Column="1"
  107. Margin="0 0 3 0"
  108. VerticalAlignment="Center"
  109. DockPanel.Dock="Right"
  110. Foreground="{DynamicResource SeconarydText}"
  111. RenderTransformOrigin="0.5,0.5"
  112. Type="ArrowDownSLine">
  113. <bpa:Icon.RenderTransform>
  114. <RotateTransform x:Name="arrowTransform" Angle="0" />
  115. </bpa:Icon.RenderTransform>
  116. </bpa:Icon>
  117. <ContentPresenter Focusable="False" SnapsToDevicePixels="True" />
  118. </DockPanel>
  119. </Border>
  120. </Grid>
  121. <ControlTemplate.Triggers>
  122. <MultiDataTrigger>
  123. <MultiDataTrigger.Conditions>
  124. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True" />
  125. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="False" />
  126. <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="False" />
  127. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="True" />
  128. </MultiDataTrigger.Conditions>
  129. </MultiDataTrigger>
  130. <Trigger Property="IsMouseOver" Value="True">
  131. <Setter TargetName="arrow" Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  132. <Setter TargetName="templateRoot" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  133. </Trigger>
  134. <Trigger Property="IsEnabled" Value="False">
  135. <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  136. </Trigger>
  137. <DataTrigger Binding="{Binding Path=(bpa:ControlHelper.IsKeyBoardFocused), RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True">
  138. <Setter TargetName="templateRoot" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  139. <DataTrigger.EnterActions>
  140. <BeginStoryboard>
  141. <Storyboard>
  142. <DoubleAnimation Storyboard.TargetName="effectBorder"
  143. Storyboard.TargetProperty="Opacity"
  144. To="1"
  145. Duration="0:0:0.25" />
  146. </Storyboard>
  147. </BeginStoryboard>
  148. </DataTrigger.EnterActions>
  149. <DataTrigger.ExitActions>
  150. <BeginStoryboard>
  151. <Storyboard>
  152. <DoubleAnimation Storyboard.TargetName="effectBorder"
  153. Storyboard.TargetProperty="Opacity"
  154. Duration="0:0:0.25" />
  155. </Storyboard>
  156. </BeginStoryboard>
  157. </DataTrigger.ExitActions>
  158. </DataTrigger>
  159. <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource Mode=Self}}" Value="True">
  160. <Setter TargetName="arrow" Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
  161. <DataTrigger.EnterActions>
  162. <BeginStoryboard>
  163. <Storyboard>
  164. <DoubleAnimation Storyboard.TargetName="arrowTransform"
  165. Storyboard.TargetProperty="Angle"
  166. To="180"
  167. Duration="0:0:0.25">
  168. <DoubleAnimation.EasingFunction>
  169. <CubicEase EasingMode="EaseOut" />
  170. </DoubleAnimation.EasingFunction>
  171. </DoubleAnimation>
  172. </Storyboard>
  173. </BeginStoryboard>
  174. </DataTrigger.EnterActions>
  175. <DataTrigger.ExitActions>
  176. <BeginStoryboard>
  177. <Storyboard>
  178. <DoubleAnimation Storyboard.TargetName="arrowTransform"
  179. Storyboard.TargetProperty="Angle"
  180. To="0"
  181. Duration="0:0:0.25">
  182. <DoubleAnimation.EasingFunction>
  183. <CubicEase EasingMode="EaseOut" />
  184. </DoubleAnimation.EasingFunction>
  185. </DoubleAnimation>
  186. </Storyboard>
  187. </BeginStoryboard>
  188. </DataTrigger.ExitActions>
  189. </DataTrigger>
  190. </ControlTemplate.Triggers>
  191. </ControlTemplate>
  192. </Setter.Value>
  193. </Setter>
  194. </Style>
  195. <ControlTemplate x:Key="RubyerComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
  196. <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
  197. <Popup x:Name="PART_Popup"
  198. Grid.ColumnSpan="2"
  199. MaxHeight="{TemplateBinding MaxDropDownHeight}"
  200. AllowsTransparency="True"
  201. HorizontalOffset="-5"
  202. IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  203. Placement="Bottom"
  204. PopupAnimation="Fade">
  205. <Popup.MinWidth>
  206. <MultiBinding Converter="{StaticResource ComboBoxPopupWidth}">
  207. <Binding ElementName="templateRoot" Path="ActualWidth" />
  208. <Binding ElementName="dropDownBorder" Path="Margin.Left" />
  209. </MultiBinding>
  210. </Popup.MinWidth>
  211. <Grid>
  212. <Border x:Name="dropDownBorder"
  213. Margin="5"
  214. Background="{DynamicResource FloatBackground}"
  215. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  216. Effect="{DynamicResource AllDirectionEffect}" />
  217. <ScrollViewer x:Name="DropDownScrollViewer"
  218. Style="{StaticResource SmallScrollViewer}"
  219. Margin="5 10">
  220. <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
  221. <ItemsPresenter x:Name="ItemsPresenter"
  222. KeyboardNavigation.DirectionalNavigation="Contained"
  223. OverridesDefaultStyle="True"
  224. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  225. </Grid>
  226. </ScrollViewer>
  227. </Grid>
  228. </Popup>
  229. <ToggleButton x:Name="toggleButton"
  230. Style="{StaticResource RubyerComboBoxToggleButton}"
  231. Grid.ColumnSpan="3"
  232. Background="{TemplateBinding Background}"
  233. BorderBrush="{TemplateBinding BorderBrush}"
  234. BorderThickness="{TemplateBinding BorderThickness}"
  235. IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
  236. <Grid SnapsToDevicePixels="True">
  237. <Grid.ColumnDefinitions>
  238. <ColumnDefinition Width="*" />
  239. <ColumnDefinition Width="Auto" />
  240. </Grid.ColumnDefinitions>
  241. <TextBox x:Name="PART_EditableTextBox"
  242. Style="{StaticResource RubyerComboBoxEditableTextBox}"
  243. Margin="{TemplateBinding Padding}"
  244. Padding="0"
  245. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  246. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  247. bpa:InputBoxHelper.InternalSpacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  248. bpa:InputBoxHelper.PostContent="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  249. bpa:InputBoxHelper.PreContent="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  250. bpa:InputBoxHelper.Watermark="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  251. IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" />
  252. <Button x:Name="clearButton"
  253. Style="{StaticResource TextButton}"
  254. Grid.Column="1"
  255. Padding="2"
  256. bpa:ButtonHelper.Shape="Circle"
  257. Foreground="{DynamicResource SeconarydText}"
  258. Visibility="Collapsed">
  259. <bpa:Icon Type="CloseLine" />
  260. </Button>
  261. </Grid>
  262. </ToggleButton>
  263. </Grid>
  264. <ControlTemplate.Triggers>
  265. <Trigger Property="IsEnabled" Value="False">
  266. <Setter TargetName="PART_EditableTextBox" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  267. </Trigger>
  268. <Trigger Property="HasItems" Value="False">
  269. <Setter TargetName="dropDownBorder" Property="Height" Value="95" />
  270. </Trigger>
  271. <MultiTrigger>
  272. <MultiTrigger.Conditions>
  273. <Condition Property="IsGrouping" Value="True" />
  274. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
  275. </MultiTrigger.Conditions>
  276. <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
  277. </MultiTrigger>
  278. <Trigger SourceName="toggleButton" Property="IsChecked" Value="True">
  279. <Setter TargetName="toggleButton" Property="IsHitTestVisible" Value="False" />
  280. </Trigger>
  281. <MultiTrigger>
  282. <MultiTrigger.Conditions>
  283. <Condition Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
  284. <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
  285. </MultiTrigger.Conditions>
  286. <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
  287. </MultiTrigger>
  288. <MultiTrigger>
  289. <MultiTrigger.Conditions>
  290. <Condition Property="IsMouseOver" Value="True" />
  291. <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
  292. </MultiTrigger.Conditions>
  293. <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
  294. </MultiTrigger>
  295. </ControlTemplate.Triggers>
  296. </ControlTemplate>
  297. <Style x:Key="RubyerComboBox" TargetType="{x:Type ComboBox}">
  298. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  299. <Setter Property="Background" Value="Transparent" />
  300. <Setter Property="BorderBrush" Value="DeepSkyBlue" />
  301. <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
  302. <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
  303. <Setter Property="Padding" Value="0 5" />
  304. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
  305. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  306. <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
  307. <Setter Property="ScrollViewer.PanningMode" Value="Both" />
  308. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  309. <Setter Property="HorizontalContentAlignment" Value="Left" />
  310. <Setter Property="VerticalContentAlignment" Value="Center" />
  311. <Setter Property="MaxDropDownHeight" Value="400" />
  312. <Setter Property="ItemContainerStyle" Value="{StaticResource RubyerComboBoxItem}" />
  313. <Setter Property="Validation.ErrorTemplate" Value="{StaticResource RubyerValidationErrorTemplate}" />
  314. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Self}}" />
  315. <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Primary}" />
  316. <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Primary}" />
  317. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  318. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.4" />
  319. <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="False" />
  320. <Setter Property="bpa:ItemsControlHelper.ItemMargin" Value="5 0.5" />
  321. <Setter Property="bpa:ItemsControlHelper.ItemPadding" Value="5" />
  322. <Setter Property="bpa:ItemsControlHelper.EnumValuesToItemsSource" Value="False" />
  323. <Setter Property="bpa:ComboBoxHelper.IsMultiSelect" Value="False" />
  324. <Setter Property="Template">
  325. <Setter.Value>
  326. <ControlTemplate TargetType="{x:Type ComboBox}">
  327. <Grid x:Name="templateRoot"
  328. Background="Transparent"
  329. SnapsToDevicePixels="True">
  330. <Popup x:Name="PART_Popup"
  331. Grid.ColumnSpan="2"
  332. MaxHeight="{TemplateBinding MaxDropDownHeight}"
  333. AllowsTransparency="True"
  334. HorizontalOffset="-5"
  335. IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  336. Placement="Bottom"
  337. PopupAnimation="Fade">
  338. <Popup.MinWidth>
  339. <MultiBinding Converter="{StaticResource ComboBoxPopupWidth}">
  340. <Binding ElementName="templateRoot" Path="ActualWidth" />
  341. <Binding ElementName="dropDownBorder" Path="Margin.Left" />
  342. </MultiBinding>
  343. </Popup.MinWidth>
  344. <Grid>
  345. <Border x:Name="dropDownBorder"
  346. Margin="5"
  347. Background="{DynamicResource FloatBackground}"
  348. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  349. Effect="{DynamicResource AllDirectionEffect}" />
  350. <ScrollViewer x:Name="DropDownScrollViewer"
  351. Style="{StaticResource SmallScrollViewer}"
  352. Margin="5 10">
  353. <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
  354. <ItemsPresenter x:Name="ItemsPresenter"
  355. KeyboardNavigation.DirectionalNavigation="Contained"
  356. OverridesDefaultStyle="True"
  357. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  358. </Grid>
  359. </ScrollViewer>
  360. </Grid>
  361. </Popup>
  362. <ToggleButton x:Name="toggleButton"
  363. Style="{StaticResource RubyerComboBoxToggleButton}"
  364. Grid.ColumnSpan="2"
  365. Background="{TemplateBinding Background}"
  366. BorderBrush="{TemplateBinding BorderBrush}"
  367. BorderThickness="{TemplateBinding BorderThickness}"
  368. IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
  369. <Grid Margin="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), Converter={StaticResource DoubleToLeftAndRightThicknessConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"
  370. bpa:GridHelper.ColumnDefinitions="Auto,*,Auto,Auto"
  371. bpa:PanelHelper.Spacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  372. <ContentControl x:Name="preContent"
  373. Grid.Column="0"
  374. VerticalAlignment="Center"
  375. Content="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  376. Foreground="{DynamicResource SeconarydText}"
  377. IsHitTestVisible="False"
  378. IsTabStop="False" />
  379. <Grid Grid.Column="1" VerticalAlignment="Center">
  380. <ContentPresenter x:Name="contentPresenter"
  381. Margin="{TemplateBinding Padding}"
  382. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  383. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  384. Content="{TemplateBinding SelectionBoxItem}"
  385. ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
  386. ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  387. ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
  388. IsHitTestVisible="False"
  389. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  390. <TextBlock x:Name="multiSelectText"
  391. Margin="{TemplateBinding Padding}"
  392. VerticalAlignment="Center"
  393. IsHitTestVisible="False"
  394. Text="{Binding Path=(bpa:ComboBoxHelper.MultiSelectText), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  395. Visibility="Collapsed" />
  396. <TextBlock x:Name="watermark"
  397. VerticalAlignment="Center"
  398. Foreground="{DynamicResource WatermarkText}"
  399. IsHitTestVisible="False"
  400. Text="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  401. </Grid>
  402. <Button x:Name="clearButton"
  403. Style="{StaticResource TextButton}"
  404. Grid.Column="2"
  405. Padding="2"
  406. bpa:ButtonHelper.Shape="Circle"
  407. Focusable="False"
  408. Foreground="{DynamicResource SeconarydText}"
  409. Visibility="Collapsed">
  410. <bpa:Icon Type="CloseLine" />
  411. </Button>
  412. <ContentControl x:Name="postContent"
  413. Grid.Column="3"
  414. VerticalAlignment="Center"
  415. Content="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  416. Foreground="{DynamicResource SeconarydText}"
  417. IsHitTestVisible="False"
  418. IsTabStop="False" />
  419. </Grid>
  420. </ToggleButton>
  421. </Grid>
  422. <ControlTemplate.Triggers>
  423. <Trigger Property="IsEnabled" Value="False">
  424. <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  425. </Trigger>
  426. <Trigger Property="HasItems" Value="False">
  427. <Setter TargetName="dropDownBorder" Property="Height" Value="100" />
  428. </Trigger>
  429. <MultiTrigger>
  430. <MultiTrigger.Conditions>
  431. <Condition Property="IsGrouping" Value="True" />
  432. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
  433. </MultiTrigger.Conditions>
  434. <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
  435. </MultiTrigger>
  436. <MultiTrigger>
  437. <MultiTrigger.Conditions>
  438. <Condition Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
  439. <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
  440. </MultiTrigger.Conditions>
  441. <!--<Setter TargetName="clearButton" Property="Visibility" Value="Visible" />-->
  442. </MultiTrigger>
  443. <MultiTrigger>
  444. <MultiTrigger.Conditions>
  445. <Condition Property="IsMouseOver" Value="True" />
  446. <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
  447. </MultiTrigger.Conditions>
  448. <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
  449. </MultiTrigger>
  450. <MultiDataTrigger>
  451. <MultiDataTrigger.Conditions>
  452. <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="False" />
  453. <Condition Binding="{Binding Path=Content, ElementName=contentPresenter, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
  454. </MultiDataTrigger.Conditions>
  455. <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
  456. </MultiDataTrigger>
  457. <Trigger Property="bpa:InputBoxHelper.IsRound" Value="True">
  458. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
  459. </Trigger>
  460. <MultiDataTrigger>
  461. <MultiDataTrigger.Conditions>
  462. <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True" />
  463. <Condition Binding="{Binding Path=Text, ElementName=multiSelectText, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
  464. </MultiDataTrigger.Conditions>
  465. <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
  466. </MultiDataTrigger>
  467. <DataTrigger Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True">
  468. <Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
  469. <Setter TargetName="multiSelectText" Property="Visibility" Value="Visible" />
  470. </DataTrigger>
  471. </ControlTemplate.Triggers>
  472. </ControlTemplate>
  473. </Setter.Value>
  474. </Setter>
  475. <Style.Triggers>
  476. <MultiDataTrigger>
  477. <MultiDataTrigger.Conditions>
  478. <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource Self}}" Value="True" />
  479. <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="False" />
  480. </MultiDataTrigger.Conditions>
  481. <Setter Property="IsTabStop" Value="False" />
  482. <Setter Property="Template" Value="{StaticResource RubyerComboBoxEditableTemplate}" />
  483. </MultiDataTrigger>
  484. <Trigger Property="IsKeyboardFocused" Value="True">
  485. <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
  486. </Trigger>
  487. <Trigger Property="IsKeyboardFocusWithin" Value="True">
  488. <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
  489. </Trigger>
  490. </Style.Triggers>
  491. </Style>
  492. <!-- Filled ComboBox -->
  493. <Style x:Key="FilledComboBox"
  494. BasedOn="{StaticResource RubyerComboBox}"
  495. TargetType="{x:Type ComboBox}">
  496. <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
  497. <Setter Property="Background" Value="{DynamicResource BorderLighter}" />
  498. <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Border}" />
  499. </Style>
  500. </ResourceDictionary>