Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Xamarin.CommunityToolkit
/// </summary>
static class ToolkitPlatform
{
static Context? context;

/// <summary>
/// Gets the <see cref="Context"/>.
/// </summary>
Expand All @@ -18,7 +20,11 @@ internal static Context Context
{
var page = Forms.Application.Current.MainPage;
var renderer = page.GetRenderer();
return renderer.View.Context ?? throw new NullReferenceException($"{nameof(Context)} cannot be null");

if (renderer?.View.Context is not null)
context = renderer.View.Context;

return renderer?.View.Context ?? context ?? throw new NullReferenceException($"{nameof(Context)} cannot be null");
}
}
}
Expand Down