public void Insert(int index, IView child) { _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class."); _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class."); _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class."); var targetIndex = VirtualView.GetLayoutHandlerIndex(child); PlatformView.AddView(child.ToPlatform(MauiContext), targetIndex); }
void UpdateContent() { _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class."); _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class."); _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class."); PlatformView.RemoveAllViews(); if (VirtualView.PresentedContent is IView view) { PlatformView.AddView(view.ToPlatform(MauiContext)); } }
public override void SetVirtualView(IView view) { base.SetVirtualView(view); _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class."); _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class."); _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class."); PlatformView.CrossPlatformMeasure = VirtualView.CrossPlatformMeasure; PlatformView.CrossPlatformArrange = VirtualView.CrossPlatformArrange; PlatformView.RemoveAllViews(); foreach (var child in VirtualView.OrderByZIndex()) { PlatformView.AddView(child.ToPlatform(MauiContext)); } }
void EnsureZIndexOrder(IView child) { if (PlatformView.ChildCount == 0) { return; } AView nativeChildView = child.ToPlatform(MauiContext !); var currentIndex = IndexOf(PlatformView, nativeChildView); if (currentIndex == -1) { return; } var targetIndex = VirtualView.GetLayoutHandlerIndex(child); if (currentIndex != targetIndex) { PlatformView.RemoveViewAt(currentIndex); PlatformView.AddView(nativeChildView, targetIndex); } }