Skip to content

Instantly share code, notes, and snippets.

@jammerxd
Last active March 10, 2016 16:40
Show Gist options
  • Save jammerxd/de9c4436fee2433304e5 to your computer and use it in GitHub Desktop.
Save jammerxd/de9c4436fee2433304e5 to your computer and use it in GitHub Desktop.
Mahapps.Metro Animated Expander Mod
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
xmlns:Converters="clr-namespace:MahApps.Metro.Converters">
<!--THIS IS THE BEGINNING OF TRANSITIONS FOR THE EXPANDER-->
<!--<Storyboard x:Key="UpTransitionEnter">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="ExpandSite"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200"
Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM"
Storyboard.TargetProperty="(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="30" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="DownTransitionEnter">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="ExpandSite"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200"
Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM"
Storyboard.TargetProperty="(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="-40" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>-->
<Storyboard x:Key="RightTransitionEnter">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="ExpandSite">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.700"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(TranslateTransform.X)"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="-30" />
<EasingDoubleKeyFrame KeyTime="00:00:00.700"
Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="LeftTransitionEnter">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="ExpandSite">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.700"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(TranslateTransform.X)"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="30" />
<EasingDoubleKeyFrame KeyTime="00:00:00.700"
Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="RightTransitionExit">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="ExpandSite">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.400"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(TranslateTransform.X)"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.700"
Value="-30">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="LeftTransitionExit">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="ExpandSite">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.400"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetProperty="(TranslateTransform.X)"
Storyboard.TargetName="BORDERTRANSLATETRANSFORM">
<SplineDoubleKeyFrame KeyTime="00:00:00"
Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.700"
Value="30">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--THIS IS THE END OF THE TRANSITIONS!-->
<Converters:ThicknessBindingConverter x:Key="ThicknessBindingConverter" />
<Style x:Key="ExpanderBaseHeaderStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Margin"
Value="4" />
<Setter Property="Padding"
Value="0" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="SnapsToDevicePixels"
Value="True" />
</Style>
<Style x:Key="ExpanderRightHeaderStyle"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource ExpanderBaseHeaderStyle}">
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Padding="{TemplateBinding Padding}">
<Grid Background="Transparent"
SnapsToDevicePixels="False">
<Grid.RowDefinitions>
<RowDefinition Height="19" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="ArrowGrid">
<Grid.LayoutTransform>
<TransformGroup>
<TransformGroup.Children>
<TransformCollection>
<RotateTransform Angle="-90" />
</TransformCollection>
</TransformGroup.Children>
</TransformGroup>
</Grid.LayoutTransform>
<Ellipse x:Name="Circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2"/>
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2" />
</Grid>
<Controls:ContentControlEx Grid.Row="1"
Margin="0,4,0,0"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="Arrow"
Property="Data"
Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
</Trigger>
<Trigger Property="IsPressed"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle"
Property="StrokeThickness"
Value="2" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpanderUpHeaderStyle"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource ExpanderBaseHeaderStyle}">
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<Grid Background="Transparent"
SnapsToDevicePixels="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid x:Name="ArrowGrid">
<Grid.LayoutTransform>
<TransformGroup>
<TransformGroup.Children>
<TransformCollection>
<RotateTransform Angle="180" />
</TransformCollection>
</TransformGroup.Children>
</TransformGroup>
</Grid.LayoutTransform>
<Ellipse x:Name="Circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2"/>
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2" />
</Grid>
<Controls:ContentControlEx Grid.Column="1"
Margin="4,0,0,0"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="true">
<Setter TargetName="Arrow"
Property="Data"
Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Arrow"
Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)"
To="360"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Arrow"
Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)"
To="180"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
</Trigger>
<Trigger Property="IsPressed"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle"
Property="StrokeThickness"
Value="2" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpanderLeftHeaderStyle"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource ExpanderRightHeaderStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<Grid Background="Transparent"
SnapsToDevicePixels="False">
<Grid.RowDefinitions>
<RowDefinition Height="19" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="ArrowGrid">
<Grid.LayoutTransform>
<TransformGroup>
<TransformGroup.Children>
<TransformCollection>
<RotateTransform Angle="90" />
</TransformCollection>
</TransformGroup.Children>
</TransformGroup>
</Grid.LayoutTransform>
<Ellipse x:Name="Circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2"/>
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2" />
</Grid>
<Controls:ContentControlEx Grid.Row="1"
Margin="0,4,0,0"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="true">
<Setter TargetName="Arrow"
Property="Data"
Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
</Trigger>
<Trigger Property="IsPressed"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle"
Property="StrokeThickness"
Value="2" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpanderDownHeaderStyle"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource ExpanderUpHeaderStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<Grid Background="Transparent"
SnapsToDevicePixels="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid x:Name="ArrowGrid">
<Grid.LayoutTransform>
<TransformGroup>
<TransformGroup.Children>
<TransformCollection>
<RotateTransform Angle="270" x:Name="ArrowAngle" />
</TransformCollection>
</TransformGroup.Children>
</TransformGroup>
</Grid.LayoutTransform>
<Ellipse x:Name="Circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2"/>
<Path x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false"
Stroke="{TemplateBinding Foreground}"
StrokeThickness="2" />
</Grid>
<Controls:ContentControlEx Grid.Column="1"
Margin="4,0,0,0"
Height="22"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<!--<Trigger Property="IsChecked"
Value="true">
<Setter TargetName="Arrow"
Property="Data"
Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>-->
<Trigger Property="IsChecked"
Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ArrowAngle"
Storyboard.TargetProperty="(RotateTransform.Angle)"
To="360"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ArrowAngle"
Storyboard.TargetProperty="(RotateTransform.Angle)"
To="270"
Duration="0:0:0.4"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource GrayBrush2}" />
</Trigger>
<Trigger Property="IsPressed"
Value="true">
<Setter TargetName="Circle"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
<Setter TargetName="Circle"
Property="StrokeThickness"
Value="2" />
<Setter TargetName="Arrow"
Property="Stroke"
Value="{DynamicResource BlackColorBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MetroExpander"
TargetType="{x:Type Expander}">
<Setter Property="Controls:ControlsHelper.ContentCharacterCasing"
Value="Upper" />
<Setter Property="Padding"
Value="5" />
<Setter Property="SnapsToDevicePixels"
Value="True" />
<Setter Property="Foreground"
Value="{DynamicResource BlackBrush}" />
<Setter Property="Background"
Value="{DynamicResource AccentColorBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource AccentColorBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="Controls:ControlsHelper.HeaderFontSize"
Value="{DynamicResource ContentFontSize}" />
<Setter Property="Controls:GroupBoxHelper.HeaderForeground"
Value="{x:Null}" />
<Setter Property="Controls:ExpanderHelper.HeaderUpStyle"
Value="{StaticResource ExpanderUpHeaderStyle}" />
<Setter Property="Controls:ExpanderHelper.HeaderDownStyle"
Value="{StaticResource ExpanderDownHeaderStyle}" />
<Setter Property="Controls:ExpanderHelper.HeaderLeftStyle"
Value="{StaticResource ExpanderLeftHeaderStyle}" />
<Setter Property="Controls:ExpanderHelper.HeaderRightStyle"
Value="{StaticResource ExpanderRightHeaderStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="DisabledVisualElement">
<SplineDoubleKeyFrame KeyTime="0"
Value="0.7" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="ExpanderRoot">
<EasingDoubleKeyFrame KeyTime="0"
Value="0.3" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="DisabledVisualElement"
Fill="{DynamicResource ControlsDisabledBrush}"
IsHitTestVisible="false"
Opacity="0" />
<DockPanel x:Name="ExpanderRoot">
<Border x:Name="HeaderSite"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True"
BorderThickness="{TemplateBinding BorderThickness}"
DockPanel.Dock="Top">
<ToggleButton x:Name="ToggleSite"
UseLayoutRounding="False"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
ContentStringFormat="{TemplateBinding HeaderStringFormat}"
FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
Controls:ControlsHelper.ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
Style="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderDownStyle)}">
<ToggleButton.Foreground>
<MultiBinding Converter="{x:Static Converters:BackgroundToForegroundConverter.Instance}">
<Binding Mode="OneWay"
Path="Background"
RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Mode="OneWay"
Path="(Controls:GroupBoxHelper.HeaderForeground)"
RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ToggleButton.Foreground>
</ToggleButton>
</Border>
<Border x:Name="ExpandSite"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True"
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:IgnoreThicknessSideType.Top}}"
DockPanel.Dock="Bottom"
Focusable="false"
Opacity="0"
Visibility="Visible">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform x:Name="BORDERTRANSLATETRANSFORM" />
</TransformGroup>
</Border.RenderTransform>
<ContentPresenter UseLayoutRounding="False"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Cursor="{TemplateBinding Cursor}" />
</Border>
</DockPanel>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsExpanded" Value="True" />
<Condition Property="ExpandDirection" Value="Up" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource LeftTransitionEnter}" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource LeftTransitionExit}" />
</MultiTrigger.ExitActions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsExpanded" Value="True" />
<Condition Property="ExpandDirection" Value="Down" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource RightTransitionEnter}" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource RightTransitionExit}" />
</MultiTrigger.ExitActions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsExpanded" Value="True" />
<Condition Property="ExpandDirection" Value="Left" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource LeftTransitionEnter}" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource LeftTransitionExit}" />
</MultiTrigger.ExitActions>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsExpanded" Value="True" />
<Condition Property="ExpandDirection" Value="Right" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource RightTransitionEnter}" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource RightTransitionExit}" />
</MultiTrigger.ExitActions>
</MultiTrigger>
<Trigger Property="ExpandDirection"
Value="Right">
<Setter TargetName="ExpandSite"
Property="DockPanel.Dock"
Value="Right" />
<Setter TargetName="ExpandSite"
Property="BorderThickness"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:IgnoreThicknessSideType.Left}}" />
<Setter TargetName="HeaderSite"
Property="DockPanel.Dock"
Value="Left" />
<Setter TargetName="ToggleSite"
Property="Style"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderRightStyle)}" />
</Trigger>
<Trigger Property="ExpandDirection"
Value="Up">
<Setter TargetName="ExpandSite"
Property="DockPanel.Dock"
Value="Top" />
<Setter TargetName="ExpandSite"
Property="BorderThickness"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:IgnoreThicknessSideType.Bottom}}" />
<Setter TargetName="HeaderSite"
Property="DockPanel.Dock"
Value="Bottom" />
<Setter TargetName="ToggleSite"
Property="Style"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderUpStyle)}" />
</Trigger>
<Trigger Property="ExpandDirection"
Value="Left">
<Setter TargetName="ExpandSite"
Property="DockPanel.Dock"
Value="Left" />
<Setter TargetName="ExpandSite"
Property="BorderThickness"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:IgnoreThicknessSideType.Right}}" />
<Setter TargetName="HeaderSite"
Property="DockPanel.Dock"
Value="Right" />
<Setter TargetName="ToggleSite"
Property="Style"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ExpanderHelper.HeaderLeftStyle)}" />
</Trigger>
<Trigger Property="IsEnabled"
Value="false">
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment