예제 #1
0
 private Control Template(PopupRoot control)
 {
     return new Border
     {
         [~Border.BackgroundProperty] = control[~PopupRoot.BackgroundProperty],
         Content = new ContentPresenter
         {
             Name = "contentPresenter",
             [~ContentPresenter.ContentProperty] = control[~PopupRoot.ContentProperty],
         }
     };
 }
예제 #2
0
        /// <summary>
        /// Shows a tooltip for the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        private static void ShowToolTip(Control control)
        {
            if (control != null)
            {
                if (popup == null)
                {
                    popup = new PopupRoot
                    {
                        Content = new ToolTip(),
                    };
                }

                var cp = MouseDevice.Instance.GetPosition(control);
                var position = control.PointToScreen(cp) + new Vector(0, 22);

                popup.Parent = control;
                ((ToolTip)popup.Content).Content = GetTip(control);
                popup.SetPosition(position);
                popup.Show();

                current = control;
            }
        }
예제 #3
0
파일: Popup.cs 프로젝트: MarkWalls/Perspex
        /// <summary>
        /// Opens the popup.
        /// </summary>
        public void Open()
        {
            if (this.popupRoot == null)
            {
                this.popupRoot = new PopupRoot(this.DependencyResolver)
                {
                    Parent = this,
                    [~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],
                };
            }

            this.popupRoot.SetPosition(this.GetPosition());
            this.topLevel.Deactivated += this.MaybeClose;
            this.popupRoot.AddHandler(PopupRoot.PointerPressedEvent, this.MaybeClose, RoutingStrategies.Bubble, true);
            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);
        }