Skip to content

Commit 8897d95

Browse files
committed
Merge branch 'ripple-color' of https://github.com/jdf3/MaterialDesignInXamlToolkit into jdf3-ripple-color
2 parents 167b2cf + d07700f commit 8897d95

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
ToolTip="Resource name: MaterialDesignRaisedAccentButton">
123123
ACCENT
124124
</Button>
125+
<Button Style="{StaticResource MaterialDesignRaisedAccentButton}"
126+
Margin="0 0 8 0"
127+
Width="150"
128+
ToolTip="Resource name: MaterialDesignRaisedAccentButton"
129+
materialDesign:RippleAssist.Feedback="#DD000000">CUSTOM RIPPLE</Button>
125130
</StackPanel>
126131
<StackPanel Grid.Row="3" Margin="256 16 0 0" Orientation="Horizontal">
127132
<Button Style="{StaticResource MaterialDesignFlatButton}" Click="ButtonBase_OnClick" ToolTip="MaterialDesignFlatButton">ACCEPT</Button>

MaterialDesignThemes.Wpf/RippleAssist.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows;
2+
using System.Windows.Media;
23

34
namespace MaterialDesignThemes.Wpf
45
{
@@ -7,7 +8,7 @@ public static class RippleAssist
78
#region ClipToBound
89

910
public static readonly DependencyProperty ClipToBoundsProperty = DependencyProperty.RegisterAttached(
10-
"ClipToBounds", typeof (bool), typeof (RippleAssist), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits));
11+
"ClipToBounds", typeof(bool), typeof(RippleAssist), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits));
1112

1213
public static void SetClipToBounds(DependencyObject element, bool value)
1314
{
@@ -16,7 +17,7 @@ public static void SetClipToBounds(DependencyObject element, bool value)
1617

1718
public static bool GetClipToBounds(DependencyObject element)
1819
{
19-
return (bool) element.GetValue(ClipToBoundsProperty);
20+
return (bool)element.GetValue(ClipToBoundsProperty);
2021
}
2122

2223
#endregion
@@ -70,5 +71,23 @@ public static double GetRippleSizeMultiplier(DependencyObject element)
7071

7172
#endregion
7273

74+
#region Feedback
75+
76+
public static readonly DependencyProperty FeedbackProperty = DependencyProperty.RegisterAttached(
77+
"Feedback", typeof(Brush), typeof(RippleAssist), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsRender));
78+
79+
public static void SetFeedback(DependencyObject element, Brush value)
80+
{
81+
element.SetValue(FeedbackProperty, value);
82+
}
83+
84+
public static Brush GetFeedback(DependencyObject element)
85+
{
86+
return (Brush)element.GetValue(FeedbackProperty);
87+
}
88+
89+
#endregion
90+
91+
7392
}
7493
}

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<Setter Property="Background" Value="Transparent" />
4040
<Setter Property="IsTabStop" Value="False" />
4141
<Setter Property="ClipToBounds" Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:RippleAssist.ClipToBounds)}" />
42-
<Setter Property="Feedback" Value="{Binding RelativeSource={RelativeSource Self}, Path=Foreground}" />
42+
<Setter Property="Feedback" Value="{Binding RelativeSource={RelativeSource Self}, Path=(local:RippleAssist.Feedback)}" />
4343
<Setter Property="Template">
4444
<Setter.Value>
4545
<ControlTemplate TargetType="{x:Type local:Ripple}">

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
2626
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
2727
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
28+
<Setter Property="wpf:RippleAssist.Feedback" Value="White" />
2829
<Setter Property="Cursor" Value="Hand"/>
2930
<Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth1" />
3031
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
@@ -50,7 +51,6 @@
5051
</Border>
5152
</AdornerDecorator>
5253
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
53-
Feedback="White"
5454
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
5555
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
5656
Padding="{TemplateBinding Padding}"
@@ -93,6 +93,7 @@
9393
<Setter Property="BorderBrush" Value="Transparent"/>
9494
<Setter Property="Cursor" Value="Hand"/>
9595
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}"/>
96+
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesignFlatButtonRipple}" />
9697
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
9798
<Setter Property="BorderThickness" Value="1"/>
9899
<Setter Property="HorizontalContentAlignment" Value="Center"/>
@@ -105,7 +106,6 @@
105106
<Grid>
106107
<Border Background="{TemplateBinding Background}" x:Name="border" CornerRadius="2">
107108
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
108-
Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
109109
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
110110
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
111111
Padding="{TemplateBinding Padding}"
@@ -130,14 +130,13 @@
130130
</Style>
131131

132132
<Style x:Key="MaterialDesignToolButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFlatButton}">
133-
<Setter Property="Foreground" Value="#616161"/>
133+
<Setter Property="Foreground" Value="#616161" />
134134
<Setter Property="Padding" Value="4"/>
135135
<Setter Property="wpf:RippleAssist.ClipToBounds" Value="False"/>
136136
<Setter Property="Template">
137137
<Setter.Value>
138138
<ControlTemplate TargetType="Button">
139139
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
140-
Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
141140
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
142141
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
143142
Padding="{TemplateBinding Padding}"
@@ -161,6 +160,7 @@
161160
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
162161
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
163162
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
163+
<Setter Property="wpf:RippleAssist.Feedback" Value="White" />
164164
<Setter Property="BorderThickness" Value="1"/>
165165
<Setter Property="Cursor" Value="Hand"/>
166166
<Setter Property="HorizontalContentAlignment" Value="Center"/>
@@ -183,7 +183,6 @@
183183
</Ellipse>
184184
</AdornerDecorator>
185185
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
186-
Feedback="White"
187186
Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True"
188187
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
189188
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<Style TargetType="{x:Type wpf:PopupBox}" x:Key="MaterialDesignPopupBox">
2121
<Setter Property="ToggleContent" Value="{StaticResource MaterialDesignPopupBoxToggleContent}" />
22+
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesignFlatButtonRipple}" />
2223
<Setter Property="HorizontalAlignment" Value="Left" />
2324
<Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth3" />
2425
<Setter Property="TextElement.FontWeight" Value="Normal" />
@@ -33,7 +34,6 @@
3334
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
3435
ClipToBounds="False"
3536
wpf:RippleAssist.IsCentered="True"
36-
Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
3737
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
3838
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
3939
Padding="{TemplateBinding Padding}"
@@ -124,6 +124,7 @@
124124
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
125125
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
126126
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
127+
<Setter Property="wpf:RippleAssist.Feedback" Value="White" />
127128
<Setter Property="PlacementMode" Value="TopAndAlignCentres" />
128129
<Setter Property="PopupMode" Value="MouseOverEager" />
129130
<Setter Property="ToolTipService.Placement" Value="Left" />
@@ -199,12 +200,11 @@
199200
<BitmapCache EnableClearType="True" SnapsToDevicePixels="True"/>
200201
</AdornerDecorator.CacheMode>
201202
<Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"
202-
Effect="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"
203-
x:Name="border">
203+
Effect="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"
204+
x:Name="border">
204205
</Ellipse>
205206
</AdornerDecorator>
206207
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
207-
Feedback="White"
208208
Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}" ClipToBounds="True"
209209
wpf:RippleAssist.IsCentered="True"
210210
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
@@ -288,8 +288,7 @@
288288
VerticalAlignment="Stretch"
289289
HorizontalAlignment="Stretch"
290290
ToolTip="{TemplateBinding ToolTip}"
291-
ToolTipService.Placement="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=(ToolTipService.Placement)}"
292-
>
291+
ToolTipService.Placement="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=(ToolTipService.Placement)}">
293292
<Grid>
294293
<ContentControl x:Name="StandardToggleContent" Content="{TemplateBinding ToggleContent}" ContentTemplate="{TemplateBinding ToggleContentTemplate}"
295294
Visibility="{TemplateBinding ToggleCheckedContent, Converter={StaticResource InvertedNullVisibilityConverter}}"/>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RatingBar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<Style TargetType="{x:Type wpf:RatingBar}">
77
<Setter Property="ClipToBounds" Value="False" />
88
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
9+
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesignFlatButtonRipple}" />
910
<Setter Property="ValueItemTemplate">
1011
<Setter.Value>
1112
<DataTemplate DataType="system:Int32">
@@ -31,7 +32,6 @@
3132
<Setter.Value>
3233
<ControlTemplate TargetType="wpf:RatingBarButton">
3334
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
34-
Feedback="{DynamicResource MaterialDesignFlatButtonRipple}"
3535
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
3636
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
3737
Padding="{TemplateBinding Padding}"

0 commit comments

Comments
 (0)