Skip to content

Commit bb048b4

Browse files
Null check fixes
1 parent 7eed078 commit bb048b4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Microsoft.Toolkit.Uwp.UI.Media/Shadows/AttachedCardShadow.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,17 @@ protected internal override void OnSizeChanged(AttachedShadowElementContext cont
305305
{
306306
Vector2 sizeAsVec2 = newSize.ToVector2();
307307

308-
CompositionRoundedRectangleGeometry geometry = context.GetResource(RoundedRectangleGeometryResourceKey);
309-
if (geometry != null)
308+
if (context.TryGetResource(RoundedRectangleGeometryResourceKey, out CompositionRoundedRectangleGeometry geometry))
310309
{
311310
geometry.Size = sizeAsVec2;
312311
}
313312

314-
CompositionVisualSurface visualSurface = context.GetResource(VisualSurfaceResourceKey);
315-
if (geometry != null)
313+
if (context.TryGetResource(VisualSurfaceResourceKey, out CompositionVisualSurface visualSurface))
316314
{
317315
visualSurface.SourceSize = sizeAsVec2;
318316
}
319317

320-
ShapeVisual shapeVisual = context.GetResource(ShapeVisualResourceKey);
321-
if (geometry != null)
318+
if (context.TryGetResource(ShapeVisualResourceKey, out ShapeVisual shapeVisual))
322319
{
323320
shapeVisual.Size = sizeAsVec2;
324321
}

0 commit comments

Comments
 (0)