C# – Forcing a WPF tooltip to stay on the screen

ctooltipwpfxaml

I have a tooltip for a Label and I want it to stay open until the user
moves the mouse to a different control.

I have tried the following properties on the tooltip:

StaysOpen="True"

and

ToolTipService.ShowDuration = "60000"

But in both cases the tooltip is only displayed for exactly 5 seconds.

Why are these values being ignored?

Best Answer

If you want to set this for just one tooltip, set the duration on the object having the Tooltip, like this:

<Label ToolTipService.ShowDuration="12000" Name="lblShowTooltip" Content="Shows tooltip">
    <Label.ToolTip>
        <ToolTip>
            <TextBlock>Hello world!</TextBlock>
        </ToolTip>
    </Label.ToolTip>
</Label>

I'd say that this design was chosen because it allows same tooltip with different timeouts on different controls.

If you want this globally for your whole app, see the accepted answer.