Skip to content

Commit

Permalink
Less interops
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Apr 12, 2024
1 parent 7e64c05 commit 8b98cfb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Core/src/Handlers/Layout/LayoutHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -119,7 +121,7 @@ void EnsureZIndexOrder(IView child)

if (currentIndex != targetIndex)
{
PlatformView.Children.Move((uint)currentIndex, (uint)targetIndex);
children.Move((uint)currentIndex, (uint)targetIndex);
}
}

Expand Down

0 comments on commit 8b98cfb

Please sign in to comment.