Skip to content

Commit

Permalink
Fix issue by clipping to the required vert space instead of double.Ma…
Browse files Browse the repository at this point in the history
…xValue (#3578)
  • Loading branch information
nicolaihenriksen committed May 31, 2024
1 parent c0ac296 commit 6a49c69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@

namespace MaterialDesignThemes.Wpf.Converters;

public class FloatingHintClippingGridConverter : IValueConverter
public class FloatingHintClippingGridConverter : IMultiValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value switch
public object? Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture)
{
if (values is not [double actualWidth, double actualHeight, double floatingScale])
{
double actualWidth => new RectangleGeometry(new Rect(new Point(0, 0), new Size(actualWidth, double.MaxValue))),
_ => null
};
return null;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
RectangleGeometry geometry = new(new Rect(new Point(0, 0), new Size(actualWidth, actualHeight * floatingScale)));
geometry.Freeze();
return geometry;
}

public object?[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<wpf:ScaleHost x:Name="ScaleHost" />
<Grid Clip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth, Converter={StaticResource FloatingHintClippingGridConverter}}">
<Grid>
<Grid.Clip>
<MultiBinding Converter="{StaticResource FloatingHintClippingGridConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="FloatingScale" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</Grid.Clip>
<Grid.RenderTransform>
<MultiBinding Converter="{StaticResource FloatingHintTranslateTransformConverter}">
<Binding ElementName="ScaleHost" Path="Scale" />
Expand Down

0 comments on commit 6a49c69

Please sign in to comment.