|
2 | 2 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
3 | 3 | xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
|
4 | 4 |
|
5 |
| - <Style x:Key="FocusVisual"> |
6 |
| - <Setter Property="Control.Template"> |
7 |
| - <Setter.Value> |
8 |
| - <ControlTemplate> |
9 |
| - <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/> |
10 |
| - </ControlTemplate> |
11 |
| - </Setter.Value> |
12 |
| - </Setter> |
13 |
| - </Style> |
14 |
| - |
15 | 5 | <Style x:Key="MaterialDesignExpanderToggleButton" TargetType="{x:Type ToggleButton}">
|
16 | 6 | <Setter Property="Width" Value="32"/>
|
17 | 7 | <Setter Property="Height" Value="32"/>
|
|
62 | 52 | </Setter.Value>
|
63 | 53 | </Setter>
|
64 | 54 | </Style>
|
65 |
| - |
| 55 | + |
| 56 | + <Style x:Key="MaterialDesignExpanderHeaderToggleButton" TargetType="{x:Type ToggleButton}"> |
| 57 | + <Setter Property="Background" Value="Transparent" /> |
| 58 | + <Setter Property="HorizontalAlignment" Value="Left" /> |
| 59 | + <Setter Property="VerticalAlignment" Value="Center" /> |
| 60 | + <Setter Property="Margin" Value="8,0" /> |
| 61 | + <Setter Property="Template"> |
| 62 | + <Setter.Value> |
| 63 | + <ControlTemplate TargetType="{x:Type ToggleButton}"> |
| 64 | + <ContentPresenter Content="{TemplateBinding Content}" VerticalAlignment="Center" /> |
| 65 | + </ControlTemplate> |
| 66 | + </Setter.Value> |
| 67 | + </Setter> |
| 68 | + </Style> |
| 69 | + |
66 | 70 | <Style x:Key="MaterialDesignExpander" TargetType="{x:Type Expander}">
|
67 | 71 | <Setter Property="Background" Value="{StaticResource MaterialDesignPaper}" />
|
68 | 72 | <Setter Property="Template">
|
69 | 73 | <Setter.Value>
|
70 | 74 | <ControlTemplate TargetType="{x:Type Expander}">
|
| 75 | + <ControlTemplate.Resources> |
| 76 | + <Storyboard x:Key="OpenContent"> |
| 77 | + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="PART_Content"> |
| 78 | + <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/> |
| 79 | + <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1"/> |
| 80 | + </DoubleAnimationUsingKeyFrames> |
| 81 | + </Storyboard> |
| 82 | + <Storyboard x:Key="CloseContent"> |
| 83 | + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="PART_Content"> |
| 84 | + <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0" /> |
| 85 | + <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0" /> |
| 86 | + </DoubleAnimationUsingKeyFrames> |
| 87 | + </Storyboard> |
| 88 | + </ControlTemplate.Resources> |
71 | 89 | <Grid>
|
72 | 90 | <Grid.RowDefinitions>
|
73 | 91 | <RowDefinition MinHeight="25" />
|
74 | 92 | <RowDefinition Name="PART_ContentRow" Height="0" />
|
75 | 93 | </Grid.RowDefinitions>
|
76 | 94 | <Border BorderThickness="0">
|
77 |
| - <!--<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0,0,0,1" CornerRadius="2,2,0,0">--> |
78 | 95 | <Grid>
|
79 | 96 | <Grid.ColumnDefinitions>
|
80 | 97 | <ColumnDefinition Width="25" />
|
|
83 | 100 | <ToggleButton IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
84 | 101 | Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True"
|
85 | 102 | Style="{StaticResource MaterialDesignExpanderToggleButton}" />
|
86 |
| - <ContentPresenter Grid.Column="1" ContentSource="Header" HorizontalAlignment="Stretch" Margin="8,0" RecognizesAccessKey="True" VerticalAlignment="Center" /> |
| 103 | + <ToggleButton Grid.Column="1" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" |
| 104 | + Style="{StaticResource MaterialDesignExpanderHeaderToggleButton}"> |
| 105 | + <ContentPresenter ContentSource="Header" HorizontalAlignment="Stretch" RecognizesAccessKey="True" VerticalAlignment="Center" /> |
| 106 | + </ToggleButton> |
87 | 107 | </Grid>
|
88 | 108 | </Border>
|
89 | 109 | <Border Grid.Row="1">
|
90 |
| - <!--<Border Grid.Row="1" x:Name="PART_Content" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" CornerRadius="0,0,2,2">--> |
91 |
| - <ContentPresenter /> |
| 110 | + <ContentPresenter Name="PART_Content"> |
| 111 | + <ContentPresenter.RenderTransform> |
| 112 | + <TransformGroup> |
| 113 | + <ScaleTransform ScaleY="0" /> |
| 114 | + <SkewTransform /> |
| 115 | + <RotateTransform /> |
| 116 | + <TranslateTransform /> |
| 117 | + </TransformGroup> |
| 118 | + </ContentPresenter.RenderTransform> |
| 119 | + </ContentPresenter> |
92 | 120 | </Border>
|
93 | 121 | </Grid>
|
94 | 122 | <ControlTemplate.Triggers>
|
95 | 123 | <Trigger Property="IsExpanded" Value="True">
|
96 | 124 | <Setter TargetName="PART_ContentRow" Property="Height" Value="{Binding ElementName=PART_Content, Path=DesiredHeight}" />
|
| 125 | + <Trigger.EnterActions> |
| 126 | + <BeginStoryboard Storyboard="{StaticResource OpenContent}" /> |
| 127 | + </Trigger.EnterActions> |
| 128 | + <Trigger.ExitActions> |
| 129 | + <BeginStoryboard Storyboard="{StaticResource CloseContent}" /> |
| 130 | + </Trigger.ExitActions> |
97 | 131 | </Trigger>
|
98 | 132 | </ControlTemplate.Triggers>
|
99 | 133 | </ControlTemplate>
|
|
0 commit comments