protected override void OnChildChanged(UIView oldChild, UIView newChild) { base.OnChildChanged(oldChild, newChild); if (_host != null) { if (oldChild != null) { _host.RemoveChild(oldChild); } if (newChild != null) { _host.AddSubview(newChild); } } }
private void CreatePopoverController() { if (_popover != null) { return; } _popover = new UIPopoverController(new UIViewController()); _host = new Grid() { Frame = _popover.ContentViewController.View.Bounds, AutoresizingMask = UIViewAutoresizing.All, TemplatedParent = this.TemplatedParent, }; _popover.ContentViewController.View.AddSubview(_host); if (Child != null) { _host.AddSubview(Child); } _popover.DidDismiss += OnPopoverDidDismiss; _popoverSubscription.Disposable = Disposable.Create(() => { if (Child != null) { Child.RemoveFromSuperview(); } _popover?.Dismiss(false); _popover.DidDismiss -= OnPopoverDidDismiss; _host.RemoveFromSuperview(); _popover = null; _host = null; }); }