@@ -362,17 +362,31 @@ public void UpdateLayout()
362
362
{
363
363
_isInUpdateLayout = true ;
364
364
365
+ // On UWP, the UpdateLayout method has an overload which accepts the desired size used by the window/app to layout the visual tree,
366
+ // then this overload without parameter is only using the internally cached last desired size.
367
+ // With Uno this method is not used for standard layouting passes, so we cannot properly internally cache the value,
368
+ // and we instead could use the LayoutInformation.GetLayoutSlot(root).
369
+ //
370
+ // The issue is that unlike UWP which will ends by requesting an UpdateLayout with the right window bounds,
371
+ // Uno instead exclusively relies on measure/arrange invalidation.
372
+ // So if we invoke the `UpdateLayout()` **before** the tree has been measured at least once
373
+ // (which is the case when using a MUX.NavigationView in the "MainPage" on iOS as OnApplyTemplate is invoked too early),
374
+ // then the whole tree will be measured at the last known value which is 0x0 and will never be invalidated.
375
+ //
376
+ // To avoid this we are instead using the Window Bounds as anyway they are the same as the root's slot.
377
+ var bounds = Windows . UI . Xaml . Window . Current . Bounds ;
378
+
365
379
#if __MACOS__ || __IOS__ // IsMeasureDirty and IsArrangeDirty are not available on iOS / macOS
366
- root . Measure ( LayoutInformation . GetLayoutSlot ( root ) . Size ) ;
367
- root . Arrange ( LayoutInformation . GetLayoutSlot ( root ) ) ;
380
+ root . Measure ( bounds . Size ) ;
381
+ root . Arrange ( bounds ) ;
368
382
#elif __ANDROID__
369
383
for ( var i = 0 ; i < MaxLayoutIterations ; i ++ )
370
384
{
371
385
// On Android, Measure and arrange are the same
372
386
if ( root . IsMeasureDirty )
373
387
{
374
- root . Measure ( LayoutInformation . GetLayoutSlot ( root ) . Size ) ;
375
- root . Arrange ( LayoutInformation . GetLayoutSlot ( root ) ) ;
388
+ root . Measure ( bounds . Size ) ;
389
+ root . Arrange ( bounds ) ;
376
390
}
377
391
else
378
392
{
@@ -384,11 +398,11 @@ public void UpdateLayout()
384
398
{
385
399
if ( root . IsMeasureDirty )
386
400
{
387
- root . Measure ( LayoutInformation . GetLayoutSlot ( root ) . Size ) ;
401
+ root . Measure ( bounds . Size ) ;
388
402
}
389
403
else if ( root . IsArrangeDirty )
390
404
{
391
- root . Arrange ( LayoutInformation . GetLayoutSlot ( root ) ) ;
405
+ root . Arrange ( bounds ) ;
392
406
}
393
407
else
394
408
{
0 commit comments