コード例 #1
0
        public void Add(IView child)
        {
            _ = TypedNativeView ?? throw new InvalidOperationException($"{nameof(TypedNativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");

            TypedNativeView.AddSubview(child.ToNative());
            TypedNativeView.SetNeedsLayout();
        }
コード例 #2
0
        public void Add(IView child)
        {
            _ = TypedNativeView ?? throw new InvalidOperationException($"{nameof(TypedNativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiApp.Current?.Context ?? throw new InvalidOperationException($"The MauiApp.Current.Context can't be null.");

            TypedNativeView.AddSubview(child.ToNative(MauiApp.Current.Context));
            TypedNativeView.SetNeedsLayout();
        }
コード例 #3
0
        public void Remove(IView child)
        {
            _ = TypedNativeView ?? throw new InvalidOperationException($"{nameof(TypedNativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");

            if (child?.Handler?.NativeView is NativeView nativeView)
            {
                nativeView.RemoveFromSuperview();
                TypedNativeView.SetNeedsLayout();
            }
        }