コード例 #1
0
        public void Add(IView child)
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} 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.");

            NativeView.AddSubview(child.ToNative(MauiContext));
            NativeView.SetNeedsLayout();
        }
コード例 #2
0
        public void Remove(IView child)
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} 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();
                NativeView.SetNeedsLayout();
            }
        }
コード例 #3
0
 /// <summary>
 /// Invalidates the layout of the selected view. For iOS, calls the SetNeedsLayout method.
 /// </summary>
 /// <param name="view">The view to invalidate.</param>
 public static void InvalidateMeasure(this _View view)
 {
     view.SetNeedsLayout();
 }