Skip to content

Commit 6a49c69

Browse files
Fix issue by clipping to the required vert space instead of double.MaxValue (#3578)
1 parent c0ac296 commit 6a49c69

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/MaterialDesignThemes.Wpf/Converters/FloatingHintClippingGridConverter.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44

55
namespace MaterialDesignThemes.Wpf.Converters;
66

7-
public class FloatingHintClippingGridConverter : IValueConverter
7+
public class FloatingHintClippingGridConverter : IMultiValueConverter
88
{
9-
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
10-
value switch
9+
public object? Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture)
10+
{
11+
if (values is not [double actualWidth, double actualHeight, double floatingScale])
1112
{
12-
double actualWidth => new RectangleGeometry(new Rect(new Point(0, 0), new Size(actualWidth, double.MaxValue))),
13-
_ => null
14-
};
13+
return null;
14+
}
1515

16-
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
16+
RectangleGeometry geometry = new(new Rect(new Point(0, 0), new Size(actualWidth, actualHeight * floatingScale)));
17+
geometry.Freeze();
18+
return geometry;
19+
}
20+
21+
public object?[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture)
1722
=> throw new NotImplementedException();
1823
}

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.SmartHint.xaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@
143143
</VisualStateGroup>
144144
</VisualStateManager.VisualStateGroups>
145145
<wpf:ScaleHost x:Name="ScaleHost" />
146-
<Grid Clip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth, Converter={StaticResource FloatingHintClippingGridConverter}}">
146+
<Grid>
147+
<Grid.Clip>
148+
<MultiBinding Converter="{StaticResource FloatingHintClippingGridConverter}">
149+
<Binding Path="ActualWidth" RelativeSource="{RelativeSource TemplatedParent}" />
150+
<Binding Path="ActualHeight" RelativeSource="{RelativeSource TemplatedParent}" />
151+
<Binding Path="FloatingScale" RelativeSource="{RelativeSource TemplatedParent}" />
152+
</MultiBinding>
153+
</Grid.Clip>
147154
<Grid.RenderTransform>
148155
<MultiBinding Converter="{StaticResource FloatingHintTranslateTransformConverter}">
149156
<Binding ElementName="ScaleHost" Path="Scale" />

0 commit comments

Comments
 (0)