How to Programmatically show a WPF/C# Windows.Control.ToolTip?

Viewed 35861

There doesn't seem to be a .Show() kind of method for the Windows.Control.ToolTip, incl in ToolTipService.

6 Answers

What you need to do is make sure the ToolTip on the control is of type ToolTip. Then you can set the IsOpen property to true like so:

ToolTip tooltip = new ToolTip{ Content = "My Tooltip" };
NameTextBox.ToolTip = tooltip;
tooltip.IsOpen = true;    

Finally i ended with this .. and it's working fantastic ..

            Popup myPopup = new Popup();
            myPopup.PlacementTarget = control; //FrameworkElement where you want to show this tooltip             
            myPopup.Placement = PlacementMode.Top;
            myPopup.PopupAnimation = PopupAnimation.Slide;

            myPopup.AllowsTransparency = true;
            TextBlock popupText = new TextBlock();
            popupText.Text = ErrorMessage; //Message you want to show
            popupText.Background = Brushes.AliceBlue;
            popupText.Foreground = Brushes.Red;
            //popupText.FontSize = 12;                
            popupText.TextWrapping = TextWrapping.Wrap;
            myPopup.Child = popupText;
            // popup1.CustomPopupPlacementCallback =
            // new CustomPopupPlacementCallback(placePopup);

            //myPopup.HorizontalOffset = control.ActualWidth - popupText.ActualWidth;
            control.ToolTip = myPopup;
            myPopup.IsOpen = true;
            myPopup.StaysOpen = false;
Related