diff --git a/Microsoft.Toolkit.Uwp.UI/Shadows/AttachedShadowBase.cs b/Microsoft.Toolkit.Uwp.UI/Shadows/AttachedShadowBase.cs index b78e2a771fc..dccd84e2121 100644 --- a/Microsoft.Toolkit.Uwp.UI/Shadows/AttachedShadowBase.cs +++ b/Microsoft.Toolkit.Uwp.UI/Shadows/AttachedShadowBase.cs @@ -174,9 +174,12 @@ public AttachedShadowElementContext GetElementContext(FrameworkElement element) /// public IEnumerable EnumerateElementContexts() { - foreach (var kvp in ShadowElementContextTable) + if (ShadowElementContextTable != null) { - yield return kvp.Value; + foreach (var kvp in ShadowElementContextTable) + { + yield return kvp.Value; + } } }