Skip to content

Commit

Permalink
Merge branch 'main' into net7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Aug 31, 2022
2 parents 68c20e5 + b8e27cd commit 14a876b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/Core/src/Platform/Android/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 7 additions & 2 deletions src/Core/src/Platform/Windows/FrameworkElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 7 additions & 2 deletions src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 14a876b

Please sign in to comment.