diff --git a/src/Core/src/Handlers/Layout/LayoutHandler.Windows.cs b/src/Core/src/Handlers/Layout/LayoutHandler.Windows.cs index 2a4836b2ca1f..644750214359 100644 --- a/src/Core/src/Handlers/Layout/LayoutHandler.Windows.cs +++ b/src/Core/src/Handlers/Layout/LayoutHandler.Windows.cs @@ -26,11 +26,12 @@ public override void SetVirtualView(IView view) PlatformView.CrossPlatformLayout = VirtualView; - PlatformView.Children.Clear(); + var children = PlatformView.Children; + children.Clear(); foreach (var child in VirtualView.OrderByZIndex()) { - PlatformView.Children.Add(child.ToPlatform(MauiContext)); + children.Add(child.ToPlatform(MauiContext)); } } @@ -108,7 +109,8 @@ void EnsureZIndexOrder(IView child) return; } - var currentIndex = PlatformView.Children.IndexOf(child.ToPlatform(MauiContext!)); + var children = PlatformView.Children; + var currentIndex = children.IndexOf(child.ToPlatform(MauiContext!)); if (currentIndex == -1) { @@ -119,7 +121,7 @@ void EnsureZIndexOrder(IView child) if (currentIndex != targetIndex) { - PlatformView.Children.Move((uint)currentIndex, (uint)targetIndex); + children.Move((uint)currentIndex, (uint)targetIndex); } }