コード例 #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);
        }
コード例 #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)
            {
                _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);
        }