Skip to content

Commit 3566eb5

Browse files
author
Helder Carvalho
committed
Added IsRippleDisabled and updated demo #328
1 parent 8e2e16f commit 3566eb5

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@
174174
Width="150"
175175
ToolTip="Resource name: MaterialDesignRaisedAccentButton"
176176
materialDesign:RippleAssist.Feedback="#DD000000">CUSTOM RIPPLE</Button>
177+
<Button Style="{StaticResource MaterialDesignRaisedAccentButton}"
178+
Margin="0 0 8 0"
179+
Width="150"
180+
ToolTip="Resource name: MaterialDesignRaisedAccentButton"
181+
materialDesign:RippleAssist.IsDisabled="True">NO RIPPLE</Button>
177182
<RepeatButton Margin="0 0 8 0" Width="100"
178183
ToolTip="Resource name: MaterialDesignRaisedButton">
179184
REPEAT

MaterialDesignThemes.Wpf/Ripple.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
118118
RippleY = point.Y - RippleSize / 2;
119119
}
120120

121-
VisualStateManager.GoToState(this, TemplateStateNormal, false);
122-
VisualStateManager.GoToState(this, TemplateStateMousePressed, true);
123-
PressedInstances.Add(this);
121+
if (!RippleAssist.GetIsDisabled(this))
122+
{
123+
VisualStateManager.GoToState(this, TemplateStateNormal, false);
124+
VisualStateManager.GoToState(this, TemplateStateMousePressed, true);
125+
PressedInstances.Add(this);
126+
}
124127

125128
base.OnPreviewMouseLeftButtonDown(e);
126129
}

MaterialDesignThemes.Wpf/RippleAssist.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,35 @@ public static bool GetIsCentered(DependencyObject element)
5454

5555
#endregion
5656

57+
#region disable
58+
59+
/// <summary>
60+
/// Set to <c>True</c> to disable ripple effect
61+
/// </summary>
62+
public static readonly DependencyProperty IsDisabledProperty = DependencyProperty.RegisterAttached(
63+
"IsDisabled", typeof(bool), typeof(RippleAssist), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits));
64+
65+
/// <summary>
66+
/// Set to <c>True</c> to disable ripple effect
67+
/// </summary>
68+
/// <param name="element"></param>
69+
/// <param name="value"></param>
70+
public static void SetIsDisabled(DependencyObject element, bool value)
71+
{
72+
element.SetValue(IsDisabledProperty, value);
73+
}
74+
75+
/// <summary>
76+
/// Set to <c>True</c> to disable ripple effect
77+
/// </summary>
78+
/// <param name="element"></param>
79+
public static bool GetIsDisabled(DependencyObject element)
80+
{
81+
return (bool)element.GetValue(IsDisabledProperty);
82+
}
83+
84+
#endregion
85+
5786
#region RippleSizeMultiplier
5887

5988
public static readonly DependencyProperty RippleSizeMultiplierProperty = DependencyProperty.RegisterAttached(

0 commit comments

Comments
 (0)