Skip to content

Commit aa813e1

Browse files
committed
allow transitions to be disabled on dialog host and drawer
1 parent c9b8e43 commit aa813e1

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
226226
{
227227
var dialogHost = (DialogHost)dependencyObject;
228228

229-
VisualStateManager.GoToState(dialogHost, dialogHost.SelectState(), true);
229+
VisualStateManager.GoToState(dialogHost, dialogHost.SelectState(), !TransitionAssist.GetDisableTransitions(dialogHost));
230230

231231
if (!dialogHost.IsOpen)
232232
{

MaterialDesignThemes.Wpf/DrawerHost.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ private void UpdateVisualStates(bool useTransitions)
117117
var anyOpen = IsLeftDrawerOpen;
118118

119119
VisualStateManager.GoToState(this,
120-
!anyOpen ? TemplateAllDrawersAllClosedStateName : TemplateAllDrawersAnyOpenStateName, useTransitions);
120+
!anyOpen ? TemplateAllDrawersAllClosedStateName : TemplateAllDrawersAnyOpenStateName, !TransitionAssist.GetDisableTransitions(this));
121121

122122
VisualStateManager.GoToState(this,
123-
IsLeftDrawerOpen ? TemplateLeftOpenStateName : TemplateLeftClosedStateName, useTransitions);
123+
IsLeftDrawerOpen ? TemplateLeftOpenStateName : TemplateLeftClosedStateName, !TransitionAssist.GetDisableTransitions(this));
124124
}
125125

126126
private static void IsLeftDrawerOpenPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
<Compile Include="ToolTipAssist.cs" />
269269
<Compile Include="RippleAssist.cs" />
270270
<Compile Include="Ripple.cs" />
271+
<Compile Include="TransitionAssist.cs" />
271272
<Compile Include="Underline.cs" />
272273
<Compile Include="ValidationAssist.cs" />
273274
<EmbeddedResource Include="Properties\Resources.resx">

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,19 @@
507507
<VisualState x:Name="Open">
508508
<Storyboard>
509509
<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="IsOpen">
510-
<DiscreteBooleanKeyFrame Value="True" />
510+
<DiscreteBooleanKeyFrame Value="True" KeyTime="0" />
511511
</BooleanAnimationUsingKeyFrames>
512512
<DoubleAnimation Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Opacity"
513+
Duration="0"
513514
To=".56" />
514515
<DoubleAnimation Storyboard.TargetName="PART_PopupContentElement" Storyboard.TargetProperty="Opacity"
516+
Duration="0"
515517
To="1" />
516518
<DoubleAnimation Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX"
519+
Duration="0"
517520
To="1" />
518521
<DoubleAnimation Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY"
522+
Duration="0"
519523
To="1" />
520524
</Storyboard>
521525
</VisualState>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Windows;
2+
3+
namespace MaterialDesignThemes.Wpf
4+
{
5+
/// <summary>
6+
/// Allows transitions to be disabled where supported.
7+
/// </summary>
8+
public static class TransitionAssist
9+
{
10+
/// <summary>
11+
/// Allows transitions to be disabled where supported. Note this is an inheritable property.
12+
/// </summary>
13+
public static readonly DependencyProperty DisableTransitionsProperty = DependencyProperty.RegisterAttached(
14+
"DisableTransitions", typeof (bool), typeof (TransitionAssist), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.Inherits));
15+
16+
/// <summary>
17+
/// Allows transitions to be disabled where supported. Note this is an inheritable property.
18+
/// </summary>
19+
public static void SetDisableTransitions(DependencyObject element, bool value)
20+
{
21+
element.SetValue(DisableTransitionsProperty, value);
22+
}
23+
24+
/// <summary>
25+
/// Allows transitions to be disabled where supported. Note this is an inheritable property.
26+
/// </summary>
27+
public static bool GetDisableTransitions(DependencyObject element)
28+
{
29+
return (bool) element.GetValue(DisableTransitionsProperty);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)