/// <inheritdoc/> protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); _topLevel = null; _popupRoot?.Dispose(); _popupRoot = null; }
/// <summary> /// Opens the popup. /// </summary> public void Open() { if (_popupRoot == null) { _popupRoot = new PopupRoot(DependencyResolver) { [~ContentControl.ContentProperty] = this[~ChildProperty], [~WidthProperty] = this[~WidthProperty], [~HeightProperty] = this[~HeightProperty], [~MinWidthProperty] = this[~MinWidthProperty], [~MaxWidthProperty] = this[~MaxWidthProperty], [~MinHeightProperty] = this[~MinHeightProperty], [~MaxHeightProperty] = this[~MaxHeightProperty], }; ((ISetLogicalParent)_popupRoot).SetParent(this); } _popupRoot.SetPosition(GetPosition()); _popupRoot.AddHandler(PointerPressedEvent, MaybeClose, RoutingStrategies.Bubble, true); if (_topLevel != null) { _topLevel.Deactivated += MaybeClose; _topLevel.AddHandler(PointerPressedEvent, MaybeClose, RoutingStrategies.Tunnel); } PopupRootCreated?.Invoke(this, EventArgs.Empty); _popupRoot.Show(); IsOpen = true; Opened?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Opens the popup. /// </summary> public void Open() { if (_popupRoot == null) { _popupRoot = new PopupRoot(DependencyResolver) { [~ContentControl.ContentProperty] = this[~ChildProperty], [~WidthProperty] = this[~WidthProperty], [~HeightProperty] = this[~HeightProperty], [~MinWidthProperty] = this[~MinWidthProperty], [~MaxWidthProperty] = this[~MaxWidthProperty], [~MinHeightProperty] = this[~MinHeightProperty], [~MaxHeightProperty] = this[~MaxHeightProperty], }; ((ISetLogicalParent)_popupRoot).SetParent(this); } _popupRoot.Position = GetPosition(); if (_topLevel == null && PlacementTarget != null) { _topLevel = PlacementTarget.GetSelfAndLogicalAncestors().First(x => x is TopLevel) as TopLevel; } if (_topLevel != null) { _topLevel.Deactivated += TopLevelDeactivated; _topLevel.AddHandler(PointerPressedEvent, PointerPressedOutside, RoutingStrategies.Tunnel); _nonClientListener = InputManager.Instance.Process.Subscribe(ListenForNonClientClick); } PopupRootCreated?.Invoke(this, EventArgs.Empty); _popupRoot.Show(); IsOpen = true; Opened?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Opens the popup. /// </summary> public void Open() { if (this.popupRoot == null) { this.popupRoot = new PopupRoot(this.DependencyResolver) { [~PopupRoot.ContentProperty] = this[~ChildProperty], [~PopupRoot.WidthProperty] = this[~WidthProperty], [~PopupRoot.HeightProperty] = this[~HeightProperty], [~PopupRoot.MinWidthProperty] = this[~MinWidthProperty], [~PopupRoot.MaxWidthProperty] = this[~MaxWidthProperty], [~PopupRoot.MinHeightProperty] = this[~MinHeightProperty], [~PopupRoot.MaxHeightProperty] = this[~MaxHeightProperty], }; ((ISetLogicalParent)this.popupRoot).SetParent(this); } this.popupRoot.SetPosition(this.GetPosition()); this.popupRoot.AddHandler(PopupRoot.PointerPressedEvent, this.MaybeClose, RoutingStrategies.Bubble, true); if (this.topLevel != null) { this.topLevel.Deactivated += this.MaybeClose; this.topLevel.AddHandler(TopLevel.PointerPressedEvent, this.MaybeClose, RoutingStrategies.Tunnel); } this.PopupRootCreated?.Invoke(this, EventArgs.Empty); this.popupRoot.Show(); this.IsOpen = true; this.Opened?.Invoke(this, EventArgs.Empty); }
private static IControl PopupRootTemplate(PopupRoot control) { return new ContentPresenter { Name = "contentPresenter", [~ContentPresenter.ContentProperty] = control[~PopupRoot.ContentProperty], }; }
/// <summary> /// Opens the popup. /// </summary> public void Open() { if (_popupRoot == null) { _popupRoot = new PopupRoot(DependencyResolver) { [~ContentControl.ContentProperty] = this[~ChildProperty], [~WidthProperty] = this[~WidthProperty], [~HeightProperty] = this[~HeightProperty], [~MinWidthProperty] = this[~MinWidthProperty], [~MaxWidthProperty] = this[~MaxWidthProperty], [~MinHeightProperty] = this[~MinHeightProperty], [~MaxHeightProperty] = this[~MaxHeightProperty], }; ((ISetLogicalParent)_popupRoot).SetParent(this); } _popupRoot.Position = GetPosition(); if (_topLevel == null && PlacementTarget != null) { _topLevel = PlacementTarget.GetSelfAndLogicalAncestors().First(x => x is TopLevel) as TopLevel; } if (_topLevel != null) { _topLevel.Deactivated += TopLevelDeactivated; _topLevel.AddHandler(PointerPressedEvent, PointerPressedOutside, RoutingStrategies.Tunnel); } PopupRootCreated?.Invoke(this, EventArgs.Empty); _popupRoot.Show(); IsOpen = true; Opened?.Invoke(this, EventArgs.Empty); }