Skip to content

Commit

Permalink
IWindow.Content can be null in Core
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Jul 23, 2024
1 parent 3c0978d commit 1282de7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
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
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Window/WindowHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void MapContent(IWindowHandler handler, IWindow window)
{
_ = handler.MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

var platformContent = window.Content.ToContainerView(handler.MauiContext);
var platformContent = window.Content!.ToContainerView(handler.MauiContext);

handler.MauiContext.GetPlatformWindow().SetContent(platformContent);

Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Window/WindowHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void MapContent(IWindowHandler handler, IWindow window)
{
_ = handler.MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

var nativeContent = window.Content.ToUIViewController(handler.MauiContext);
var nativeContent = window.Content!.ToUIViewController(handler.MauiContext);

handler.PlatformView.RootViewController = nativeContent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal void SetToolbarElement(IToolbarElement toolbarElement)
_toolbarElement = toolbarElement;
}

internal void Connect(IView view, IMauiContext? mauiContext = null)
internal void Connect(IView? view, IMauiContext? mauiContext = null)
{
ClearPlatformParts();

Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Platform/iOS/ElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static partial class ElementExtensions

public static UIViewController ToUIViewController(this IElement view, IMauiContext context)
{
var platformView = view.ToPlatform(context);
var platformView = view?.ToPlatform(context);
if (view?.Handler is IPlatformViewHandler nvh && nvh.ViewController != null)
return nvh.ViewController;

Expand Down

0 comments on commit 1282de7

Please sign in to comment.