Skip to content

Commit d0e4c1d

Browse files
authored
Reverting fix from #2454 (#2491)
Rather than trying to apply the appropriate clip will instead just allow clipping to be toggled on and off. Default will be off.
1 parent abdd49f commit d0e4c1d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

MaterialDesignThemes.Wpf/Card.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public static readonly DependencyProperty ContentClipProperty
3737
= ContentClipPropertyKey.DependencyProperty;
3838
#endregion
3939

40+
41+
public static readonly DependencyProperty ClipContentProperty =
42+
DependencyProperty.Register("ClipContent", typeof(bool), typeof(Card), new PropertyMetadata(false));
43+
44+
public bool ClipContent
45+
{
46+
get => (bool)GetValue(ClipContentProperty);
47+
set => SetValue(ClipContentProperty, value);
48+
}
49+
4050
static Card()
4151
{
4252
DefaultStyleKeyProperty.OverrideMetadata(typeof(Card), new FrameworkPropertyMetadata(typeof(Card)));

MaterialDesignThemes.Wpf/Converters/SizeToRectConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace MaterialDesignThemes.Wpf.Converters
77
{
8+
[Obsolete("This will be removed in the 5.0 release as it is no longer used")]
89
public class CardClipConverter : IMultiValueConverter
910
{
1011
/// <summary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Card.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
<ResourceDictionary.MergedDictionaries>
77
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
88
</ResourceDictionary.MergedDictionaries>
9-
10-
<converters:CardClipConverter x:Key="CardClipConverter" />
119

1210
<ControlTemplate TargetType="{x:Type wpf:Card}" x:Key="CardTemplate">
1311
<ControlTemplate.Resources>
1412
<converters:ShadowEdgeConverter x:Key="ShadowEdgeConverter" />
1513
</ControlTemplate.Resources>
16-
<Grid Background="Transparent" Clip="{TemplateBinding ContentClip}">
14+
<Grid Background="Transparent">
1715
<AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
1816
<AdornerDecorator.OpacityMask>
1917
<MultiBinding Converter="{StaticResource ShadowEdgeConverter}">
@@ -39,6 +37,11 @@
3937
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}">
4038
</ContentPresenter>
4139
</Grid>
40+
<ControlTemplate.Triggers>
41+
<Trigger Property="ClipContent" Value="True">
42+
<Setter Property="Clip" TargetName="ContentPresenter" Value="{Binding ContentClip, RelativeSource={RelativeSource TemplatedParent}}" />
43+
</Trigger>
44+
</ControlTemplate.Triggers>
4245
</ControlTemplate>
4346
<Style TargetType="{x:Type wpf:Card}">
4447
<Setter Property="Template" Value="{StaticResource CardTemplate}" />

0 commit comments

Comments
 (0)