Skip to content

Commit 9e9cbb9

Browse files
committed
right drawer animation working
1 parent 89e682a commit 9e9cbb9

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

MaterialDesignThemes.Wpf/Converters/DrawerOffsetConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1818

1919
if (parameter is bool && (bool)parameter)
2020
{
21-
return 0 - d;
22-
//return new Thickness(0, 0, 0 - d, 0);
21+
return new Thickness(0, 0, 0 - d, 0);
2322
}
2423

2524
return 0 - d;

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@
658658
<Style TargetType="{x:Type local:DrawerHost}">
659659
<Setter Property="local:ShadowAssist.ShadowDepth" Value="Depth3" />
660660
<Setter Property="LeftDrawerBackground" Value="{DynamicResource MaterialDesignPaper}" />
661+
<Setter Property="RightDrawerBackground" Value="{DynamicResource MaterialDesignPaper}" />
661662
<Setter Property="IsTabStop" Value="False" />
662663
<Setter Property="Template">
663664
<Setter.Value>
@@ -776,23 +777,23 @@
776777
<VisualStateGroup.Transitions>
777778
<VisualTransition From="RightDrawerClosed" To="RightDrawerOpen">
778779
<Storyboard>
779-
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="RightDrawerTranslateTransform">
780-
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.4">
781-
<EasingDoubleKeyFrame.EasingFunction>
780+
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="RightDrawerGrid">
781+
<EasingThicknessKeyFrame Value="0" KeyTime="0:0:0.4">
782+
<EasingThicknessKeyFrame.EasingFunction>
782783
<SineEase EasingMode="EaseOut" />
783-
</EasingDoubleKeyFrame.EasingFunction>
784-
</EasingDoubleKeyFrame>
785-
</DoubleAnimationUsingKeyFrames>
784+
</EasingThicknessKeyFrame.EasingFunction>
785+
</EasingThicknessKeyFrame>
786+
</ThicknessAnimationUsingKeyFrames>
786787
<DoubleAnimation Storyboard.TargetName="RightDrawerShadow" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.04" />
787788
</Storyboard>
788789
</VisualTransition>
789790
<VisualTransition From="RightDrawerOpen" To="RightDrawerClosed">
790791
<Storyboard>
791-
<DoubleAnimation Storyboard.TargetProperty="X" Storyboard.TargetName="RightDrawerTranslateTransform" Duration="0:0:0.4">
792-
<DoubleAnimation.EasingFunction>
792+
<ThicknessAnimation Storyboard.TargetProperty="Margin" Storyboard.TargetName="RightDrawerGrid" Duration="0:0:0.4">
793+
<ThicknessAnimation.EasingFunction>
793794
<SineEase EasingMode="EaseOut" />
794-
</DoubleAnimation.EasingFunction>
795-
</DoubleAnimation>
795+
</ThicknessAnimation.EasingFunction>
796+
</ThicknessAnimation>
796797
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RightDrawerShadow" Storyboard.TargetProperty="Opacity">
797798
<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.36" />
798799
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.4">
@@ -807,13 +808,13 @@
807808
<VisualState x:Name="RightDrawerOpen">
808809
<Storyboard>
809810
<DoubleAnimation Storyboard.TargetName="RightDrawerShadow" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0" />
810-
<DoubleAnimation Storyboard.TargetProperty="X" Storyboard.TargetName="RightDrawerTranslateTransform" To="0" Duration="0"/>
811+
<ThicknessAnimation Storyboard.TargetProperty="Margin" Storyboard.TargetName="RightDrawerGrid" To="0 0 0 0" Duration="0"/>
811812
</Storyboard>
812813
</VisualState>
813814
<VisualState x:Name="RightDrawerClosed">
814815
<Storyboard>
815816
<DoubleAnimation Storyboard.TargetName="RightDrawerShadow" Storyboard.TargetProperty="Opacity" From="0" To="0" Duration="0" />
816-
<DoubleAnimation Storyboard.TargetProperty="X" Storyboard.TargetName="RightDrawerTranslateTransform" Duration="0"/>
817+
<ThicknessAnimation Storyboard.TargetProperty="Margin" Storyboard.TargetName="RightDrawerGrid" Duration="0"/>
817818
</Storyboard>
818819
</VisualState>
819820
</VisualStateGroup>
@@ -841,11 +842,9 @@
841842
</AdornerDecorator>
842843
<ContentPresenter Content="{TemplateBinding LeftDrawerContent}" ContentTemplate="{TemplateBinding LeftDrawerContentTemplate}" ContentStringFormat="{TemplateBinding LeftDrawerContentStringFormat}" />
843844
</Grid>
844-
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Right">
845-
<Grid.RenderTransform>
846-
<TranslateTransform x:Name="RightDrawerTranslateTransform"
847-
X="{Binding ElementName=RootGrid, Path=ActualWidth, Converter={StaticResource DrawerOffsetConverter}, ConverterParameter={StaticResource True}}" />
848-
</Grid.RenderTransform>
845+
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Right"
846+
x:Name="RightDrawerGrid"
847+
Margin="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth, Converter={StaticResource DrawerOffsetConverter}, ConverterParameter={StaticResource True}}">
849848
<AdornerDecorator>
850849
<AdornerDecorator.CacheMode>
851850
<BitmapCache EnableClearType="True" SnapsToDevicePixels="True"/>

0 commit comments

Comments
 (0)