Expander.xaml 10 KB

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