ExpanderStyle.xaml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
  3. <Setter Property="Template">
  4. <Setter.Value>
  5. <ControlTemplate TargetType="{x:Type ToggleButton}">
  6. <Border Padding="{TemplateBinding Padding}">
  7. <Grid Background="Transparent" SnapsToDevicePixels="False">
  8. <Grid.ColumnDefinitions>
  9. <ColumnDefinition Width="auto" />
  10. <ColumnDefinition Width="19" />
  11. </Grid.ColumnDefinitions>
  12. <Path
  13. x:Name="arrow"
  14. Grid.Column="1"
  15. HorizontalAlignment="Center"
  16. VerticalAlignment="Center"
  17. Data="M4 5.00023L8.00012 0.000115851H-0.000115851L4 5.00023Z"
  18. Fill="#8F96A7"
  19. SnapsToDevicePixels="false"
  20. Visibility="Collapsed" />
  21. <Path
  22. x:Name="arrow2"
  23. Grid.Column="1"
  24. HorizontalAlignment="Center"
  25. VerticalAlignment="Center"
  26. Data="M5.00023 4L0.000115514 -0.000116188L0.000116188 8.00012L5.00023 4Z"
  27. Fill="#8F96A7"
  28. SnapsToDevicePixels="false" />
  29. <ContentPresenter
  30. Margin="4,0,0,0"
  31. HorizontalAlignment="Left"
  32. VerticalAlignment="Center"
  33. RecognizesAccessKey="True"
  34. SnapsToDevicePixels="True" />
  35. </Grid>
  36. </Border>
  37. <ControlTemplate.Triggers>
  38. <Trigger Property="IsChecked" Value="true">
  39. <Setter TargetName="arrow" Property="Visibility" Value="Visible" />
  40. <Setter TargetName="arrow2" Property="Visibility" Value="Collapsed" />
  41. </Trigger>
  42. <Trigger Property="IsMouseOver" Value="true" />
  43. <Trigger Property="IsPressed" Value="true" />
  44. <Trigger Property="IsEnabled" Value="false" />
  45. </ControlTemplate.Triggers>
  46. </ControlTemplate>
  47. </Setter.Value>
  48. </Setter>
  49. </Style>
  50. <Style x:Key="PromotionExpanderStyle" TargetType="{x:Type Expander}">
  51. <Setter Property="Background" Value="Transparent" />
  52. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  53. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  54. <Setter Property="BorderBrush" Value="Transparent" />
  55. <Setter Property="BorderThickness" Value="1" />
  56. <Setter Property="Template">
  57. <Setter.Value>
  58. <ControlTemplate TargetType="{x:Type Expander}">
  59. <Border
  60. Background="{TemplateBinding Background}"
  61. BorderBrush="{TemplateBinding BorderBrush}"
  62. BorderThickness="{TemplateBinding BorderThickness}"
  63. CornerRadius="3"
  64. SnapsToDevicePixels="true">
  65. <DockPanel>
  66. <ToggleButton
  67. x:Name="HeaderSite"
  68. MinWidth="0"
  69. MinHeight="0"
  70. Margin="1"
  71. Padding="{TemplateBinding Padding}"
  72. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  73. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  74. Content="{TemplateBinding Header}"
  75. ContentTemplate="{TemplateBinding HeaderTemplate}"
  76. ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
  77. DockPanel.Dock="Top"
  78. FontFamily="{TemplateBinding FontFamily}"
  79. FontSize="{TemplateBinding FontSize}"
  80. FontStretch="{TemplateBinding FontStretch}"
  81. FontStyle="{TemplateBinding FontStyle}"
  82. FontWeight="{TemplateBinding FontWeight}"
  83. Foreground="{TemplateBinding Foreground}"
  84. IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  85. Style="{StaticResource ExpanderDownHeaderStyle}" />
  86. <ContentPresenter
  87. x:Name="ExpandSite"
  88. Margin="{TemplateBinding Padding}"
  89. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  90. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  91. DockPanel.Dock="Bottom"
  92. Focusable="false"
  93. Visibility="Collapsed" />
  94. </DockPanel>
  95. </Border>
  96. <ControlTemplate.Triggers>
  97. <Trigger Property="IsExpanded" Value="true">
  98. <Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
  99. </Trigger>
  100. <Trigger Property="ExpandDirection" Value="Right">
  101. <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Right" />
  102. <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Left" />
  103. </Trigger>
  104. <Trigger Property="ExpandDirection" Value="Up">
  105. <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Top" />
  106. <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Bottom" />
  107. </Trigger>
  108. <Trigger Property="ExpandDirection" Value="Left">
  109. <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Left" />
  110. <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Right" />
  111. </Trigger>
  112. <Trigger Property="IsEnabled" Value="false" />
  113. </ControlTemplate.Triggers>
  114. </ControlTemplate>
  115. </Setter.Value>
  116. </Setter>
  117. </Style>
  118. <Style x:Key="ExpanderHeaderFocusVisual">
  119. <Setter Property="Control.Template">
  120. <Setter.Value>
  121. <ControlTemplate>
  122. <Border>
  123. <Rectangle
  124. Margin="0"
  125. SnapsToDevicePixels="true"
  126. Stroke="Black"
  127. StrokeDashArray="1 2"
  128. StrokeThickness="1" />
  129. </Border>
  130. </ControlTemplate>
  131. </Setter.Value>
  132. </Setter>
  133. </Style>
  134. <SolidColorBrush x:Key="Expander.MouseOver.Circle.Stroke" Color="#FF5593FF" />
  135. <SolidColorBrush x:Key="Expander.MouseOver.Circle.Fill" Color="#FFF3F9FF" />
  136. <SolidColorBrush x:Key="Expander.MouseOver.Arrow.Stroke" Color="#FF000000" />
  137. <SolidColorBrush x:Key="Expander.Pressed.Circle.Stroke" Color="#FF3C77DD" />
  138. <SolidColorBrush x:Key="Expander.Pressed.Circle.Fill" Color="#FFD9ECFF" />
  139. <SolidColorBrush x:Key="Expander.Pressed.Arrow.Stroke" Color="#FF000000" />
  140. <SolidColorBrush x:Key="Expander.Disabled.Circle.Stroke" Color="#FFBCBCBC" />
  141. <SolidColorBrush x:Key="Expander.Disabled.Circle.Fill" Color="#FFE6E6E6" />
  142. <SolidColorBrush x:Key="Expander.Disabled.Arrow.Stroke" Color="#FF707070" />
  143. <SolidColorBrush x:Key="Expander.Static.Circle.Fill" Color="#FFFFFFFF" />
  144. <SolidColorBrush x:Key="Expander.Static.Circle.Stroke" Color="#FF333333" />
  145. <SolidColorBrush x:Key="Expander.Static.Arrow.Stroke" Color="#FF333333" />
  146. <Style x:Key="GropExpanderStyle" TargetType="{x:Type ToggleButton}">
  147. <Setter Property="Template">
  148. <Setter.Value>
  149. <ControlTemplate TargetType="{x:Type ToggleButton}">
  150. <Border Padding="{TemplateBinding Padding}">
  151. <Grid Background="Transparent" SnapsToDevicePixels="False">
  152. <Grid.ColumnDefinitions>
  153. <ColumnDefinition Width="*" />
  154. <ColumnDefinition Width="19" />
  155. </Grid.ColumnDefinitions>
  156. <Ellipse
  157. x:Name="circle"
  158. Width="19"
  159. Height="19"
  160. HorizontalAlignment="Center"
  161. VerticalAlignment="Center"
  162. Fill="{StaticResource Expander.Static.Circle.Fill}"
  163. Stroke="{StaticResource Expander.Static.Circle.Stroke}"
  164. Visibility="Collapsed" />
  165. <Rectangle Grid.Column="0" />
  166. <!--<Polygon
  167. x:Name="Collapsed"
  168. Grid.Column="1"
  169. Margin="0,0,12,0"
  170. HorizontalAlignment="Center"
  171. VerticalAlignment="Center"
  172. Fill="Black"
  173. Points="11 2 5 8 11 14"
  174. SnapsToDevicePixels="false"
  175. Stroke="{StaticResource Expander.Static.Arrow.Stroke}"
  176. StrokeThickness="2">
  177. <Polygon.RenderTransform>
  178. <TransformGroup>
  179. <TranslateTransform X="8" Y="8" />
  180. <ScaleTransform ScaleX="-1" ScaleY="1" />
  181. <TranslateTransform X="25" Y="-8" />
  182. </TransformGroup>
  183. </Polygon.RenderTransform>
  184. </Polygon>-->
  185. <Path
  186. Name="arrowdown"
  187. Grid.Column="1"
  188. Margin="0,0,5,0"
  189. HorizontalAlignment="Right"
  190. VerticalAlignment="Center"
  191. Data="M6 7.56427L2.03039 3.59467L0.969727 4.65533L5.46967 9.15526C5.76256 9.44816 6.23743 9.44816 6.53033 9.15526L11.0303 4.65533L9.9696 3.59467L6 7.56427Z"
  192. Fill="Black" />
  193. <Path
  194. Name="Collapsed"
  195. Grid.Column="1"
  196. Margin="0,0,5,0"
  197. HorizontalAlignment="Right"
  198. VerticalAlignment="Center"
  199. Data="M7.56438 5.99999L3.59473 9.96964L4.65539 11.0303L9.15537 6.53032C9.44826 6.23743 9.44826 5.76255 9.15537 5.46966L4.65539 0.969675L3.59473 2.03033L7.56438 5.99999Z"
  200. Fill="Black" />
  201. <!--<Polygon
  202. x:Name="arrowdown"
  203. Grid.Column="1"
  204. Margin="0,0,12,0"
  205. HorizontalAlignment="Center"
  206. VerticalAlignment="Center"
  207. Fill="Black"
  208. Points="11 2 5 8 11 14"
  209. SnapsToDevicePixels="false"
  210. Stroke="{StaticResource Expander.Static.Arrow.Stroke}"
  211. StrokeThickness="2"
  212. Visibility="Collapsed">
  213. <Polygon.RenderTransform>
  214. <TransformGroup>
  215. <TranslateTransform X="8" Y="8" />
  216. <RotateTransform Angle="-90" />
  217. <TranslateTransform X="-5" Y="22" />
  218. </TransformGroup>
  219. </Polygon.RenderTransform>
  220. </Polygon>-->
  221. <ContentPresenter
  222. Grid.Column="0"
  223. Margin="0,0,0,0"
  224. HorizontalAlignment="Stretch"
  225. VerticalAlignment="Center"
  226. RecognizesAccessKey="True"
  227. SnapsToDevicePixels="True" />
  228. </Grid>
  229. </Border>
  230. <ControlTemplate.Triggers>
  231. <Trigger Property="IsChecked" Value="true">
  232. <Setter TargetName="Collapsed" Property="Visibility" Value="Collapsed" />
  233. <Setter TargetName="arrowdown" Property="Visibility" Value="Visible" />
  234. </Trigger>
  235. <Trigger Property="IsChecked" Value="False">
  236. <Setter TargetName="Collapsed" Property="Visibility" Value="Visible" />
  237. <Setter TargetName="arrowdown" Property="Visibility" Value="Collapsed" />
  238. </Trigger>
  239. <Trigger Property="IsMouseOver" Value="true">
  240. <Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.MouseOver.Circle.Stroke}" />
  241. <Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.MouseOver.Circle.Fill}" />
  242. <Setter TargetName="Collapsed" Property="Stroke" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}" />
  243. <Setter TargetName="arrowdown" Property="Stroke" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}" />
  244. </Trigger>
  245. <Trigger Property="IsPressed" Value="true">
  246. <Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.Pressed.Circle.Stroke}" />
  247. <Setter TargetName="circle" Property="StrokeThickness" Value="1.5" />
  248. <Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.Pressed.Circle.Fill}" />
  249. <Setter TargetName="Collapsed" Property="Stroke" Value="{StaticResource Expander.Pressed.Arrow.Stroke}" />
  250. <Setter TargetName="arrowdown" Property="Stroke" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}" />
  251. </Trigger>
  252. <Trigger Property="IsEnabled" Value="false">
  253. <Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.Disabled.Circle.Stroke}" />
  254. <Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.Disabled.Circle.Fill}" />
  255. <Setter TargetName="Collapsed" Property="Stroke" Value="{StaticResource Expander.Disabled.Arrow.Stroke}" />
  256. <Setter TargetName="arrowdown" Property="Stroke" Value="{StaticResource Expander.Disabled.Arrow.Stroke}" />
  257. </Trigger>
  258. </ControlTemplate.Triggers>
  259. </ControlTemplate>
  260. </Setter.Value>
  261. </Setter>
  262. </Style>
  263. <Style x:Key="GropExpanderHeader" TargetType="{x:Type Expander}">
  264. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  265. <Setter Property="Background" Value="#FFFFFF" />
  266. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  267. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  268. <Setter Property="BorderBrush" Value="Transparent" />
  269. <Setter Property="BorderThickness" Value="1" />
  270. <Setter Property="Template">
  271. <Setter.Value>
  272. <ControlTemplate TargetType="{x:Type Expander}">
  273. <Border
  274. Margin="0,8"
  275. Background="{TemplateBinding Background}"
  276. BorderBrush="{TemplateBinding BorderBrush}"
  277. BorderThickness="{TemplateBinding BorderThickness}"
  278. CornerRadius="4"
  279. SnapsToDevicePixels="true">
  280. <DockPanel>
  281. <ContentPresenter
  282. x:Name="ExpandSite"
  283. Margin="{TemplateBinding Padding}"
  284. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  285. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  286. DockPanel.Dock="Bottom"
  287. Focusable="false"
  288. Visibility="Collapsed" />
  289. <ToggleButton
  290. x:Name="HeaderSite"
  291. MinWidth="0"
  292. MinHeight="0"
  293. Margin="1"
  294. Padding="{TemplateBinding Padding}"
  295. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  296. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  297. Content="{TemplateBinding Header}"
  298. ContentTemplate="{TemplateBinding HeaderTemplate}"
  299. ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
  300. DockPanel.Dock="Top"
  301. FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
  302. FontFamily="{TemplateBinding FontFamily}"
  303. FontSize="{TemplateBinding FontSize}"
  304. FontStretch="{TemplateBinding FontStretch}"
  305. FontStyle="{TemplateBinding FontStyle}"
  306. FontWeight="{TemplateBinding FontWeight}"
  307. Foreground="{TemplateBinding Foreground}"
  308. IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  309. Style="{StaticResource GropExpanderStyle}" />
  310. </DockPanel>
  311. </Border>
  312. <ControlTemplate.Triggers>
  313. <Trigger Property="IsExpanded" Value="true">
  314. <Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
  315. </Trigger>
  316. <Trigger Property="IsExpanded" Value="false">
  317. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  318. </Trigger>
  319. </ControlTemplate.Triggers>
  320. </ControlTemplate>
  321. </Setter.Value>
  322. </Setter>
  323. </Style>
  324. </ResourceDictionary>