What is the least intrusive way to display WPF tooltip on focus?

Posted by Andrey Shchekin on Stack Overflow See other posts from Stack Overflow or by Andrey Shchekin
Published on 2010-05-02T13:09:56Z Indexed on 2010/05/02 18:17 UTC
Read the original article Hit count: 485

Filed under:
|

What is the minimum number of steps required to display a tooltip when the following control gets focus?

<TextBox ToolTip="Hello there!" ... />

I tried the following in GotFocus

    private void ..._GotFocus(object sender, RoutedEventArgs e) {
        var element = (FrameworkElement)sender;
        var tooltip = element.ToolTip;
        if (!(tooltip is ToolTip)) {
            tooltip = new ToolTip { Content = tooltip };
            element.ToolTip = tooltip;
        }

        ((ToolTip)tooltip).IsOpen = true;
    }

However, it seems to ignore the ToolTipService.Placement for this control and SystemParameters.ToolTipPopupAnimationKey set up level higher.

How can I make it work and honor all settings that generally work for tooltips (except the timing, obviously)?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about tooltip