Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.CreatePopup C# (CSharp) Method

CreatePopup() private method

Creates a ToolTip control that either wraps the currently set TrayToolTip control or the ToolTipText string.
If TrayToolTip itself is already a ToolTip instance, it will be used directly.
We use a ToolTip rather than Popup because there was no way to prevent a popup from causing cyclic open/close commands if it was placed under the mouse. ToolTip internally uses a Popup of its own, but takes advance of Popup's internal UIElement.IsHitTestVisible property which prevents this issue.
private CreatePopup ( ) : void
return void
        private void CreatePopup()
        {
            //check if the item itself is a popup
            Popup popup = TrayPopup as Popup;

            if (popup == null && TrayPopup != null)
            {
                //create an invisible popup that hosts the UIElement
                popup = new Popup();
                popup.AllowsTransparency = true;

                //don't animate by default - devs can use attached
                //events or override
                popup.PopupAnimation = PopupAnimation.None;

                //the CreateRootPopup method outputs binding errors in the debug window because
                //it tries to bind to "Popup-specific" properties in case they are provided by the child.
                //We don't need that so just assign the control as the child.
                popup.Child = TrayPopup;

                //do *not* set the placement target, as it causes the popup to become hidden if the
                //TaskbarIcon's parent is hidden, too. At runtime, the parent can be resolved through
                //the ParentTaskbarIcon attached dependency property:
                //popup.PlacementTarget = this;

                popup.Placement = PlacementMode.AbsolutePoint;
                popup.StaysOpen = false;
            }

            //the popup explicitly gets the DataContext of this instance.
            //If there is no DataContext, the TaskbarIcon assigns itself
            if (popup != null)
            {
                UpdateDataContext(popup, null, DataContext);
            }

            //store a reference to the used tooltip
            SetTrayPopupResolved(popup);
        }