Пример #1
0
        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);
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
        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);
            }
        }