Skip to content

Commit bba01d7

Browse files
Merge pull request #4549 from chenjt2001/patch-1
Fix AttachedDropShadow size changes abnormally
2 parents 0864016 + 59cd9fe commit bba01d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Microsoft.Toolkit.Uwp.UI/Shadows/AttachedDropShadow.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ protected override CompositionBrush GetShadowMask(AttachedShadowElementContext c
290290
// Create a ShapeVisual so that our geometry can be rendered to a visual
291291
var shapeVisual = context.GetResource(ShapeVisualResourceKey) ??
292292
context.AddResource(ShapeVisualResourceKey, context.Compositor.CreateShapeVisual());
293-
shapeVisual.Shapes.Add(shape);
293+
294+
if (!shapeVisual.Shapes.Contains(shape))
295+
{
296+
shapeVisual.Shapes.Add(shape);
297+
}
294298

295299
// Create a CompositionVisualSurface, which renders our ShapeVisual to a texture
296300
var visualSurface = context.GetResource(VisualSurfaceResourceKey) ??
@@ -344,6 +348,7 @@ protected internal override void OnSizeChanged(AttachedShadowElementContext cont
344348
context.SpriteVisual.Offset = context.Element.CoordinatesFrom(CastTo).ToVector3();
345349

346350
UpdateShadowClip(context);
351+
UpdateShadowMask(context);
347352

348353
base.OnSizeChanged(context, newSize, previousSize);
349354
}

0 commit comments

Comments
 (0)