ExpanderStyle.xaml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
  4. <Setter Property="Template">
  5. <Setter.Value>
  6. <ControlTemplate TargetType="{x:Type ToggleButton}">
  7. <Border Padding="{TemplateBinding Padding}">
  8. <Grid Background="Transparent" SnapsToDevicePixels="False">
  9. <Grid.ColumnDefinitions>
  10. <ColumnDefinition Width="auto"/>
  11. <ColumnDefinition Width="19"/>
  12. </Grid.ColumnDefinitions>
  13. <Path x:Name="arrow" Visibility="Collapsed" Grid.Column="1" Data="M4 5.00023L8.00012 0.000115851H-0.000115851L4 5.00023Z" HorizontalAlignment="Center" Fill="#8F96A7" SnapsToDevicePixels="false" VerticalAlignment="Center"/>
  14. <Path x:Name="arrow2" Grid.Column="1" Data="M5.00023 4L0.000115514 -0.000116188L0.000116188 8.00012L5.00023 4Z" HorizontalAlignment="Center" Fill="#8F96A7" SnapsToDevicePixels="false" VerticalAlignment="Center"/>
  15. <ContentPresenter HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
  16. </Grid>
  17. </Border>
  18. <ControlTemplate.Triggers>
  19. <Trigger Property="IsChecked" Value="true">
  20. <Setter Property="Visibility" TargetName="arrow" Value="Visible"/>
  21. <Setter Property="Visibility" TargetName="arrow2" Value="Collapsed"/>
  22. </Trigger>
  23. <Trigger Property="IsMouseOver" Value="true">
  24. </Trigger>
  25. <Trigger Property="IsPressed" Value="true">
  26. </Trigger>
  27. <Trigger Property="IsEnabled" Value="false">
  28. </Trigger>
  29. </ControlTemplate.Triggers>
  30. </ControlTemplate>
  31. </Setter.Value>
  32. </Setter>
  33. </Style>
  34. <Style x:Key="PromotionExpanderStyle" TargetType="{x:Type Expander}">
  35. <Setter Property="Background" Value="Transparent"/>
  36. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  37. <Setter Property="VerticalContentAlignment" Value="Stretch"/>
  38. <Setter Property="BorderBrush" Value="Transparent"/>
  39. <Setter Property="BorderThickness" Value="1"/>
  40. <Setter Property="Template">
  41. <Setter.Value>
  42. <ControlTemplate TargetType="{x:Type Expander}">
  43. <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" SnapsToDevicePixels="true">
  44. <DockPanel>
  45. <ToggleButton x:Name="HeaderSite" Margin="1" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" DockPanel.Dock="Top" FontStretch="{TemplateBinding FontStretch}" Foreground="{TemplateBinding Foreground}" FontStyle="{TemplateBinding FontStyle}" FontFamily="{TemplateBinding FontFamily}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" Style="{StaticResource ExpanderDownHeaderStyle}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
  46. <ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed"/>
  47. </DockPanel>
  48. </Border>
  49. <ControlTemplate.Triggers>
  50. <Trigger Property="IsExpanded" Value="true">
  51. <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
  52. </Trigger>
  53. <Trigger Property="ExpandDirection" Value="Right">
  54. <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
  55. <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
  56. </Trigger>
  57. <Trigger Property="ExpandDirection" Value="Up">
  58. <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
  59. <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
  60. </Trigger>
  61. <Trigger Property="ExpandDirection" Value="Left">
  62. <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
  63. <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
  64. </Trigger>
  65. <Trigger Property="IsEnabled" Value="false">
  66. </Trigger>
  67. </ControlTemplate.Triggers>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. </ResourceDictionary>