Generic.xaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:UI="clr-namespace:CustomUI">
  5. <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
  6. <SolidColorBrush x:Key="Brush.Item.MouseOver.Background" Color="#E2E2E2" />
  7. <SolidColorBrush x:Key="Brush.Item.Selected.Background" Color="#6452A4" />
  8. <SolidColorBrush x:Key="Brush.Item.MouseOver.Foreground" Color="#000000" />
  9. <SolidColorBrush x:Key="Brush.Item.Selected.Foreground" Color="#FFFFFF" />
  10. <SolidColorBrush x:Key="Light.Border.Normal" Color="#D7DDE4" />
  11. <SolidColorBrush x:Key="Light.Border.MouseOver" Color="#6452A4" />
  12. <SolidColorBrush x:Key="ComboBox.Normal.Background" Color="#FFFFFF" />
  13. <SolidColorBrush x:Key="ComboBox.BorderBrush" Color="#ABADB3" />
  14. <SolidColorBrush x:Key="ComboBox.Disabled.Foreground" Color="#888" />
  15. <SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#eeeeee" />
  16. <SolidColorBrush x:Key="ComboBox.Disabled.BorderBrush" Color="#888888" />
  17. <SolidColorBrush x:Key="ComboBox.Popup.BorderBrush" Color="#C8C8C8" />
  18. <PathGeometry x:Key="Arrow.Down" Figures="M191.814654 383.980301 832.184323 383.980301 512 767.996418Z" />
  19. <PathGeometry x:Key="Arrow.Up" Figures="M832.185 640.020h-640.37l320.184-384.016z" />
  20. <ControlTemplate x:Key="ComboBoxToggleButtonTemplate" TargetType="{x:Type UI:ZToggleButton}">
  21. <Grid Background="Transparent">
  22. <Grid.ColumnDefinitions>
  23. <ColumnDefinition Width="*" />
  24. <ColumnDefinition Width="auto" />
  25. </Grid.ColumnDefinitions>
  26. <Border
  27. x:Name="ShadowBorder"
  28. Grid.ColumnSpan="2"
  29. Background="#FFFFFF"
  30. CornerRadius="{TemplateBinding CornerRadius}"
  31. SnapsToDevicePixels="True"
  32. UseLayoutRounding="True">
  33. <Border.Effect>
  34. <DropShadowEffect
  35. BlurRadius="5"
  36. Opacity="0.2"
  37. ShadowDepth="0"
  38. Color="Transparent" />
  39. </Border.Effect>
  40. </Border>
  41. <Border
  42. Name="Border"
  43. Grid.ColumnSpan="2"
  44. Background="{StaticResource ComboBox.Normal.Background}"
  45. BorderBrush="{StaticResource Light.Border.Normal}"
  46. BorderThickness="1,1,1,1"
  47. CornerRadius="{TemplateBinding CornerRadius}"
  48. SnapsToDevicePixels="True"
  49. UseLayoutRounding="True" />
  50. <Border
  51. Name="ButtonBorder"
  52. Grid.Column="1"
  53. Margin="1,1,1,1"
  54. Padding="5,0,8,0"
  55. Background="{StaticResource ComboBox.Normal.Background}"
  56. CornerRadius="{Binding CornerRadius, ElementName=Border}">
  57. <Path
  58. Name="Arrow"
  59. Grid.Column="1"
  60. Width="10"
  61. HorizontalAlignment="Center"
  62. VerticalAlignment="Center"
  63. Data="{StaticResource Arrow.Down}"
  64. Fill="{StaticResource ComboBox.BorderBrush}"
  65. RenderTransformOrigin="0.5,0.5"
  66. SnapsToDevicePixels="True"
  67. Stretch="Uniform"
  68. UseLayoutRounding="True">
  69. <Path.RenderTransform>
  70. <TransformGroup>
  71. <ScaleTransform />
  72. <SkewTransform />
  73. <RotateTransform />
  74. <TranslateTransform />
  75. </TransformGroup>
  76. </Path.RenderTransform>
  77. </Path>
  78. </Border>
  79. <VisualStateManager.VisualStateGroups>
  80. <VisualStateGroup x:Name="CheckStates">
  81. <VisualState x:Name="Checked">
  82. <Storyboard>
  83. <DoubleAnimation
  84. Storyboard.TargetName="Arrow"
  85. Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
  86. To="180"
  87. Duration="0:0:0.2" />
  88. <ColorAnimation
  89. Storyboard.TargetName="ShadowBorder"
  90. Storyboard.TargetProperty="(Border.Effect).(DropShadowEffect.Color)"
  91. To="Brown"
  92. Duration="0:0:0.2" />
  93. </Storyboard>
  94. </VisualState>
  95. <VisualState x:Name="Unchecked">
  96. <Storyboard>
  97. <DoubleAnimation
  98. Storyboard.TargetName="Arrow"
  99. Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
  100. To="0"
  101. Duration="0:0:0.2" />
  102. <ColorAnimation
  103. Storyboard.TargetName="ShadowBorder"
  104. Storyboard.TargetProperty="(Border.Effect).(DropShadowEffect.Color)"
  105. To="Transparent"
  106. Duration="0:0:0.2" />
  107. </Storyboard>
  108. </VisualState>
  109. </VisualStateGroup>
  110. </VisualStateManager.VisualStateGroups>
  111. </Grid>
  112. <ControlTemplate.Triggers>
  113. <Trigger Property="IsMouseOver" Value="True">
  114. <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource Light.Border.MouseOver}" />
  115. </Trigger>
  116. <MultiTrigger>
  117. <MultiTrigger.Conditions>
  118. <Condition Property="ToggleButton.IsChecked" Value="True" />
  119. <Condition Property="IsMouseOver" Value="False" />
  120. </MultiTrigger.Conditions>
  121. <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource Light.Border.MouseOver}" />
  122. </MultiTrigger>
  123. <Trigger Property="UIElement.IsEnabled" Value="False">
  124. <Setter TargetName="Border" Property="Panel.Background" Value="{StaticResource ComboBox.Disabled.Background}" />
  125. <Setter TargetName="Border" Property="Border.BorderBrush" Value="{StaticResource ComboBox.Disabled.BorderBrush}" />
  126. <Setter TargetName="ButtonBorder" Property="Panel.Background" Value="{StaticResource ComboBox.Disabled.Background}" />
  127. <Setter TargetName="ButtonBorder" Property="Border.BorderBrush" Value="{StaticResource ComboBox.Disabled.BorderBrush}" />
  128. <Setter Property="TextElement.Foreground" Value="{StaticResource ComboBox.Disabled.Foreground}" />
  129. <Setter TargetName="Arrow" Property="Stroke" Value="#999" />
  130. <Setter TargetName="Arrow" Property="StrokeThickness" Value="0" />
  131. <Setter Property="Cursor" Value="No" />
  132. </Trigger>
  133. </ControlTemplate.Triggers>
  134. </ControlTemplate>
  135. <Style TargetType="UI:CheckComboBoxItem">
  136. <Setter Property="Background" Value="Transparent" />
  137. <Setter Property="Template">
  138. <Setter.Value>
  139. <ControlTemplate TargetType="UI:CheckComboBoxItem">
  140. <Border
  141. Padding="5"
  142. Background="{TemplateBinding Background}"
  143. BorderBrush="{StaticResource ComboBox.Popup.BorderBrush}"
  144. BorderThickness="0">
  145. <Grid>
  146. <Grid.ColumnDefinitions>
  147. <ColumnDefinition Width="auto" />
  148. <ColumnDefinition />
  149. </Grid.ColumnDefinitions>
  150. <UI:FlatCheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=UI:CheckComboBoxItem}}" />
  151. <ContentPresenter
  152. Grid.Column="1"
  153. Margin="5,0,0,0"
  154. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  155. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  156. Content="{TemplateBinding Content}"
  157. ContentTemplate="{TemplateBinding ContentTemplate}" />
  158. </Grid>
  159. </Border>
  160. <ControlTemplate.Triggers>
  161. <Trigger Property="IsEnabled" Value="False">
  162. <Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  163. </Trigger>
  164. <Trigger Property="IsMouseOver" Value="True">
  165. <Setter Property="Background" Value="{StaticResource Brush.Item.MouseOver.Background}" />
  166. <Setter Property="Foreground" Value="{StaticResource Brush.Item.MouseOver.Foreground}" />
  167. </Trigger>
  168. <!--<Trigger Property="IsSelected" Value="True">
  169. <Setter Property="Background" Value="{StaticResource Brush.Item.Selected.Background}" />
  170. <Setter Property="Foreground" Value="{StaticResource Brush.Item.Selected.Foreground}" />
  171. </Trigger>-->
  172. </ControlTemplate.Triggers>
  173. </ControlTemplate>
  174. </Setter.Value>
  175. </Setter>
  176. </Style>
  177. <Style TargetType="{x:Type UI:CheckComboBox}">
  178. <Setter Property="Background" Value="Transparent" />
  179. <Setter Property="BorderBrush" Value="Transparent" />
  180. <Setter Property="BorderThickness" Value="1" />
  181. <Setter Property="Foreground" Value="#3F3F3F" />
  182. <Setter Property="Padding" Value="5,0,25,0" />
  183. <Setter Property="HorizontalContentAlignment" Value="Left" />
  184. <Setter Property="VerticalContentAlignment" Value="Center" />
  185. <Setter Property="SnapsToDevicePixels" Value="True" />
  186. <Setter Property="UseLayoutRounding" Value="True" />
  187. <Setter Property="Template">
  188. <Setter.Value>
  189. <ControlTemplate TargetType="{x:Type UI:CheckComboBox}">
  190. <Grid>
  191. <UI:ZToggleButton
  192. x:Name="toggleButton"
  193. ClickMode="Press"
  194. Focusable="False"
  195. IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
  196. Template="{StaticResource ComboBoxToggleButtonTemplate}" />
  197. <ContentPresenter
  198. x:Name="PART_ContentSite"
  199. Margin="{TemplateBinding Padding}"
  200. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  201. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  202. Content="{TemplateBinding Content}"
  203. IsHitTestVisible="False" />
  204. <Popup
  205. Name="PART_Popup"
  206. MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"
  207. MaxHeight="{TemplateBinding MaxDropDownHeight}"
  208. AllowsTransparency="True"
  209. IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  210. Placement="Bottom"
  211. StaysOpen="False"
  212. VerticalOffset="1">
  213. <Grid
  214. Name="DropDown"
  215. Width="{TemplateBinding FrameworkElement.ActualWidth}"
  216. MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}"
  217. Margin="10,0,10,10"
  218. SnapsToDevicePixels="True">
  219. <Grid.RowDefinitions>
  220. <RowDefinition Height="auto" />
  221. <RowDefinition />
  222. </Grid.RowDefinitions>
  223. <Border
  224. Grid.RowSpan="2"
  225. Background="#FFFFFF"
  226. CornerRadius="3"
  227. SnapsToDevicePixels="True"
  228. UseLayoutRounding="True">
  229. <Border.Effect>
  230. <DropShadowEffect
  231. BlurRadius="7"
  232. Opacity="0.2"
  233. ShadowDepth="0"
  234. Color="Brown" />
  235. </Border.Effect>
  236. </Border>
  237. <Border
  238. Name="DropDownBorder"
  239. Grid.RowSpan="2"
  240. Background="#FFFFFF"
  241. BorderBrush="{StaticResource ComboBox.Popup.BorderBrush}"
  242. BorderThickness="1"
  243. CornerRadius="3"
  244. SnapsToDevicePixels="True"
  245. UseLayoutRounding="True" />
  246. <UI:ZTextBox
  247. x:Name="PART_FilterTextBox"
  248. Height="26"
  249. Margin="5,5,5,3"
  250. UI:WatermarkAdorner.Watermark="{TemplateBinding FilterBoxWatermark}"
  251. Visibility="{Binding IsShowFilterBox, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
  252. <UI:ZScrollViewer
  253. Grid.Row="1"
  254. Margin="0,3,0,3"
  255. SnapsToDevicePixels="True">
  256. <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
  257. </UI:ZScrollViewer>
  258. </Grid>
  259. </Popup>
  260. </Grid>
  261. <ControlTemplate.Triggers>
  262. <Trigger Property="IsEnabled" Value="False">
  263. <Setter Property="Cursor" Value="No" />
  264. </Trigger>
  265. </ControlTemplate.Triggers>
  266. </ControlTemplate>
  267. </Setter.Value>
  268. </Setter>
  269. </Style>
  270. </ResourceDictionary>