Search code examples
wpftooltipmouseevent

wpf tooltip on mouseover and mouseout


What I am trying to do is have the tool tip show once a mouse over occurs. The ToolTip will not turn off until a mouse out.

Only a mouse out will allow the ToolTip to close.

The customer has a requirement where they want the ToolTip to stay up indefinite until a mouse out happens.

Additional: Is there a way only to close the tooltip on mouse out, and not mouse move?

The area that the mouse will be over is a rectangle and only when I move out of the rectangle should the tool tip close.

Thanks.


Solution

  • Your question isn't completely clear, and I'm not sure what you're looking for, but the things that will affect ToolTip duration follow:

    ToolTipService.InitialShowDelay - Length of time in milliseconds between hovering over a control and when the tooltip appears. 0 = instant.

    ToolTipService.ShowDuration - Length of time in milliseconds a tooltip will hang around while the mouse is over it. Setting it really high will be effectively a "never turn off" option, but there isn't a true always option.

    ToolTipService.BetweenShowDelay - Once a tooltip pops up, this is the amount of time that must pass before InitialShowDelay is again observed.

    Example:

    <TextBox ToolTipService.InitialShowDelay="5000" 
    ToolTipService.ShowDuration="2000" 
    ToolTipService.BetweenShowDelay="10000" 
    ToolTip="This is a tool tip." />
    

    With this, when you hover over the TextBox, a tooltip will show up after five seconds. It will hang around for two seconds. And until you haven't looked at a tooltip for 10 seconds, there will be no delay between hover and pop-up.