Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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)
            {
                var window = _topLevel as Window;
                if (window != null)
                {
                    window.Deactivated += WindowDeactivated;
                }
                else
                {
                    var parentPopuproot = _topLevel as PopupRoot;
                    if (parentPopuproot != null && parentPopuproot.Parent != null)
                    {
                        ((Popup)(parentPopuproot.Parent)).Closed += ParentClosed;
                    }
                }
                _topLevel.AddHandler(PointerPressedEvent, PointerPressedOutside, RoutingStrategies.Tunnel);
                _nonClientListener = InputManager.Instance.Process.Subscribe(ListenForNonClientClick);
            }

            PopupRootCreated?.Invoke(this, EventArgs.Empty);

            _popupRoot.Show();

            _ignoreIsOpenChanged = true;
            IsOpen = true;
            _ignoreIsOpenChanged = false;

            Opened?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 3
0
        /// <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);
        }