Expander.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style x:Key="ExpanderHeaderFocusVisual">
  4. <Setter Property="Control.Template">
  5. <Setter.Value>
  6. <ControlTemplate>
  7. <Border>
  8. <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/>
  9. </Border>
  10. </ControlTemplate>
  11. </Setter.Value>
  12. </Setter>
  13. </Style>
  14. <SolidColorBrush x:Key="Expander_Header_BG" Color="#FF439BD8"/>
  15. <SolidColorBrush x:Key="Expander_Header_BD" Color="Black"/>
  16. <SolidColorBrush x:Key="Expander_Header_BG_HighLight" Color="#FFD6E4FF"/>
  17. <SolidColorBrush x:Key="Expander_InnerHighlight" Color="#FF9FCDED"/>
  18. <SolidColorBrush x:Key="Expander_InnerShadow" Color="#FF003A62"/>
  19. <SolidColorBrush x:Key="Expander_BG_MouseOver" Color="#FF227BB8"/>
  20. <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
  21. <Setter Property="FontSize" Value="14"/>
  22. <Setter Property="MinWidth" Value="100"/>
  23. <Setter Property="FontFamily" Value="Arial"/>
  24. <Setter Property="BorderBrush" Value="{DynamicResource Expander_Header_BD}"/>
  25. <Setter Property="Background" Value="{DynamicResource Expander_Header_BG}"/>
  26. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  27. <Setter Property="Border.CornerRadius" Value="5"/>
  28. <Setter Property="Template">
  29. <Setter.Value>
  30. <ControlTemplate TargetType="{x:Type ToggleButton}">
  31. <Grid Cursor="Hand" Background="Transparent">
  32. <Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" CornerRadius="{TemplateBinding Border.CornerRadius}" Background="{TemplateBinding Background}">
  33. <Border x:Name="InnerBD_Highlight" BorderThickness="2,2,0,0" BorderBrush="{DynamicResource Expander_InnerHighlight}" CornerRadius="4">
  34. <Border x:Name="InnerBD_Shadow" BorderThickness="0,0,2,2" BorderBrush="{DynamicResource Expander_InnerShadow}" CornerRadius="4" Padding="3">
  35. <Grid SnapsToDevicePixels="False">
  36. <Grid.ColumnDefinitions>
  37. <ColumnDefinition />
  38. <ColumnDefinition Width="17"/>
  39. </Grid.ColumnDefinitions>
  40. <Grid Grid.Column="1">
  41. <Ellipse Stroke="{DynamicResource Expander_InnerHighlight}" StrokeThickness="1" Width="15" Height="15"/>
  42. <Rectangle x:Name="Path1" Fill="White" Height="2" Width="9"/>
  43. <Rectangle x:Name="Path2" Fill="White" Height="9" Width="2"/>
  44. </Grid>
  45. <ContentPresenter HorizontalAlignment="Left" Margin="5,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
  46. </Grid>
  47. </Border>
  48. </Border>
  49. </Border>
  50. </Grid>
  51. <ControlTemplate.Triggers>
  52. <Trigger Property="IsChecked" Value="true">
  53. <Setter Property="Visibility" TargetName="Path2" Value="Collapsed"/>
  54. <Setter Property="Border.CornerRadius" TargetName="OuterBorder" Value="5,5,0,0"/>
  55. <Setter Property="Border.CornerRadius" TargetName="InnerBD_Highlight" Value="4,4,0,0"/>
  56. <Setter Property="Border.CornerRadius" TargetName="InnerBD_Shadow" Value="4,4,0,0"/>
  57. <Setter Property="BorderThickness" TargetName="InnerBD_Shadow" Value="0,0,2,0"/>
  58. </Trigger>
  59. <Trigger Property="IsMouseOver" Value="true">
  60. <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource Expander_BG_MouseOver}"/>
  61. </Trigger>
  62. <Trigger Property="IsPressed" Value="true">
  63. <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource Expander_BG_MouseOver}"/>
  64. </Trigger>
  65. </ControlTemplate.Triggers>
  66. </ControlTemplate>
  67. </Setter.Value>
  68. </Setter>
  69. </Style>
  70. <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
  71. <Setter Property="FontSize" Value="14"/>
  72. <Setter Property="FontFamily" Value="Arial"/>
  73. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  74. <Setter Property="Background" Value="{DynamicResource Expander_Header_BG}"/>
  75. <Setter Property="BorderBrush" Value="{DynamicResource Expander_Header_BD}"/>
  76. <Setter Property="Border.CornerRadius" Value="2"/>
  77. <Setter Property="Opacity" Value="1"/>
  78. <Setter Property="Template">
  79. <Setter.Value>
  80. <ControlTemplate TargetType="{x:Type ToggleButton}">
  81. <Grid Cursor="Hand" Background="Transparent">
  82. <Grid.LayoutTransform>
  83. <TransformGroup>
  84. <TransformGroup.Children>
  85. <TransformCollection>
  86. <RotateTransform Angle="-90"/>
  87. </TransformCollection>
  88. </TransformGroup.Children>
  89. </TransformGroup>
  90. </Grid.LayoutTransform>
  91. <Grid SnapsToDevicePixels="False" Margin="0,5">
  92. <Grid.ColumnDefinitions>
  93. <ColumnDefinition Width="17"/>
  94. <ColumnDefinition />
  95. </Grid.ColumnDefinitions>
  96. <Border x:Name="OuterBorder" Grid.Column="0" HorizontalAlignment="Right" Height="15" BorderBrush="{DynamicResource Expander_Header_BD}" BorderThickness="1" Background="{DynamicResource Expander_Header_BG}" CornerRadius="2" VerticalAlignment="Center" Width="15">
  97. <Grid>
  98. <Rectangle x:Name="Path1" Fill="White" Height="2" Width="9">
  99. <Rectangle.LayoutTransform>
  100. <TransformGroup>
  101. <TransformGroup.Children>
  102. <TransformCollection>
  103. <RotateTransform Angle="-90"/>
  104. </TransformCollection>
  105. </TransformGroup.Children>
  106. </TransformGroup>
  107. </Rectangle.LayoutTransform>
  108. </Rectangle>
  109. <Rectangle x:Name="Path2" Fill="White" Height="9" Width="2">
  110. <Rectangle.LayoutTransform>
  111. <TransformGroup>
  112. <TransformGroup.Children>
  113. <TransformCollection>
  114. <RotateTransform Angle="-90"/>
  115. </TransformCollection>
  116. </TransformGroup.Children>
  117. </TransformGroup>
  118. </Rectangle.LayoutTransform>
  119. </Rectangle>
  120. </Grid>
  121. </Border>
  122. <ContentPresenter Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0" RecognizesAccessKey="True" SnapsToDevicePixels="True"/>
  123. </Grid>
  124. </Grid>
  125. <ControlTemplate.Triggers>
  126. <Trigger Property="IsChecked" Value="true">
  127. <Setter Property="Visibility" TargetName="Path2" Value="Collapsed"/>
  128. <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource Expander_Header_BG_HighLight}"/>
  129. <Setter Property="Fill" TargetName="Path1" Value="Black"/>
  130. </Trigger>
  131. <Trigger Property="IsMouseOver" Value="true"/>
  132. <Trigger Property="IsPressed" Value="true">
  133. <Setter Property="Background" TargetName="OuterBorder" Value="{DynamicResource Expander_Header_BG_HighLight}"/>
  134. </Trigger>
  135. </ControlTemplate.Triggers>
  136. </ControlTemplate>
  137. </Setter.Value>
  138. </Setter>
  139. </Style>
  140. <Style TargetType="{x:Type Expander}">
  141. <Setter Property="BorderThickness" Value="0"/>
  142. <Setter Property="Template">
  143. <Setter.Value>
  144. <ControlTemplate TargetType="{x:Type Expander}">
  145. <Grid>
  146. <DockPanel>
  147. <ToggleButton x:Name="HeaderSite"
  148. ContentTemplate="{TemplateBinding HeaderTemplate}"
  149. ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
  150. Content="{TemplateBinding Header}"
  151. DockPanel.Dock="Top"
  152. FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
  153. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  154. IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  155. MinWidth="0"
  156. MinHeight="0"
  157. Style="{StaticResource ExpanderDownHeaderStyle}"
  158. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
  159. <ContentPresenter x:Name="ExpandSite" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" DockPanel.Dock="Bottom"/>
  160. </DockPanel>
  161. </Grid>
  162. <ControlTemplate.Triggers>
  163. <Trigger Property="IsExpanded" Value="true">
  164. <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
  165. </Trigger>
  166. <Trigger Property="ExpandDirection" Value="Right">
  167. <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
  168. <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
  169. <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
  170. </Trigger>
  171. <Trigger Property="IsEnabled" Value="false">
  172. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  173. </Trigger>
  174. </ControlTemplate.Triggers>
  175. </ControlTemplate>
  176. </Setter.Value>
  177. </Setter>
  178. </Style>
  179. </ResourceDictionary>