Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IWindow.Content can be null in Core #23775

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
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 @@ -136,7 +136,7 @@ static List<IVisualTreeElement> GetVisualTreeElementsWindowsInternal(IVisualTree
var visualElements = new List<IVisualTreeElement>();
if (visualElement is IWindow window)
{
uiElement = window.Content.ToPlatform();
uiElement = window.Content?.ToPlatform();
}
else if (visualElement is IView view)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Core/src/Platform/iOS/ElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public static partial class ElementExtensions

public static UIViewController ToUIViewController(this IElement view, IMauiContext context)
{
var platformView = view.ToPlatform(context);
// The returned value is not used here, but this method is used to set
// up the platform view and handler. So, do not delete!
var _ = view?.ToPlatform(context);
if (view?.Handler is IPlatformViewHandler nvh && nvh.ViewController != null)
return nvh.ViewController;

Expand Down
Loading