diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 1e5cdc9744..7728302aad 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -165,9 +165,9 @@ namespace Avalonia.Controls.Shapes { property.Changed.Subscribe(e => { - if (e.Sender is TShape) + if (e.Sender is TShape shape) { - AffectsGeometryInvalidate(e); + AffectsGeometryInvalidate(shape, e); } }); } @@ -318,13 +318,8 @@ namespace Avalonia.Controls.Shapes return (size, transform); } - private static void AffectsGeometryInvalidate(AvaloniaPropertyChangedEventArgs e) + private static void AffectsGeometryInvalidate(Shape control, AvaloniaPropertyChangedEventArgs e) { - if (!(e.Sender is Shape control)) - { - return; - } - // If the geometry is invalidated when Bounds changes, only invalidate when the Size // portion changes. if (e.Property == BoundsProperty)