diff --git a/src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.iOS.cs index fe455f4240b1..050e862ccd7d 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.iOS.cs @@ -26,6 +26,11 @@ public IEnumerable GetChildren() protected Size MeasureChildOverride(View view, Size slotSize) { + if (view is null) + { + return default; + } + var ret = view .SizeThatFits(slotSize.LogicalToPhysicalPixels()) .PhysicalToLogicalPixels() diff --git a/src/Uno.UI/UI/Xaml/Controls/Primitives/LayoutInformation.mobile.cs b/src/Uno.UI/UI/Xaml/Controls/Primitives/LayoutInformation.mobile.cs index 35463c72adb5..63a6e1c4db2a 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Primitives/LayoutInformation.mobile.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Primitives/LayoutInformation.mobile.cs @@ -56,6 +56,12 @@ internal static Size GetDesiredSize(UIElement element) [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Size GetDesiredSize(object view) { + if (view is null) + { + // TODO: should we let it break or return default? + return default; + } + switch (view) { case UIElement iue: diff --git a/src/Uno.UI/UI/Xaml/Controls/StackPanel/StackPanel.Layout.cs b/src/Uno.UI/UI/Xaml/Controls/StackPanel/StackPanel.Layout.cs index ee13f1127020..c8344eb01032 100644 --- a/src/Uno.UI/UI/Xaml/Controls/StackPanel/StackPanel.Layout.cs +++ b/src/Uno.UI/UI/Xaml/Controls/StackPanel/StackPanel.Layout.cs @@ -51,7 +51,10 @@ protected override Size MeasureOverride(Size availableSize) for (int i = 0; i < count; i++) { - var view = Children[i]; + if (Children[i] is not { } view) + { + continue; + } var measuredSize = MeasureElement(view, slotSize); view.EnsureLayoutStorage();