diff --git a/src/Core/src/Platform/Android/ViewExtensions.cs b/src/Core/src/Platform/Android/ViewExtensions.cs index 6af19cf952d8..d8c61c765067 100644 --- a/src/Core/src/Platform/Android/ViewExtensions.cs +++ b/src/Core/src/Platform/Android/ViewExtensions.cs @@ -448,8 +448,16 @@ internal static Graphics.Rect GetBoundingBox(this View? platformView) context.FromPixels((float)rect.Height())); } - internal static bool IsLoaded(this View frameworkElement) => - frameworkElement.IsAttachedToWindow; + internal static bool IsLoaded(this View frameworkElement) + { + if (frameworkElement == null) + return false; + + if (frameworkElement.IsDisposed()) + return false; + + return frameworkElement.IsAttachedToWindow; + } internal static IDisposable OnLoaded(this View frameworkElement, Action action) { diff --git a/src/Core/src/Platform/Windows/FrameworkElementExtensions.cs b/src/Core/src/Platform/Windows/FrameworkElementExtensions.cs index c8a404211db1..bbf1c5be9540 100644 --- a/src/Core/src/Platform/Windows/FrameworkElementExtensions.cs +++ b/src/Core/src/Platform/Windows/FrameworkElementExtensions.cs @@ -197,8 +197,13 @@ internal static void TryUpdateResource(this FrameworkElement element, object new } } - internal static bool IsLoaded(this FrameworkElement frameworkElement) => - frameworkElement.IsLoaded; + internal static bool IsLoaded(this FrameworkElement frameworkElement) + { + if (frameworkElement == null) + return false; + + return frameworkElement.IsLoaded; + } internal static IDisposable OnLoaded(this FrameworkElement frameworkElement, Action action) { diff --git a/src/Core/src/Platform/iOS/ViewExtensions.cs b/src/Core/src/Platform/iOS/ViewExtensions.cs index 7d87efd7fd4d..7a6bfdc30009 100644 --- a/src/Core/src/Platform/iOS/ViewExtensions.cs +++ b/src/Core/src/Platform/iOS/ViewExtensions.cs @@ -577,8 +577,13 @@ public static void UpdateToolTip(this UIView platformView, ToolTip? tooltip) internal static IWindow? GetHostedWindow(this UIView? view) => GetHostedWindow(view?.Window); - internal static bool IsLoaded(this UIView uiView) => - uiView.Window != null; + internal static bool IsLoaded(this UIView uiView) + { + if (uiView == null) + return false; + + return uiView.Window != null; + } internal static IDisposable OnLoaded(this UIView uiView, Action action) {