关于鼠标悬停和鼠标移出的 wpf 工具提示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5533721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:44:38  来源:igfitidea点击:

wpf tooltip on mouseover and mouseout

wpftooltipmouseevent

提问by nitefrog

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.

谢谢。

回答by Bryan Walker

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:

您的问题并不完全清楚,我不确定您在寻找什么,但会影响 ToolTip 持续时间的因素如下:

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

ToolTipService.InitialShowDelay- 悬停在控件上和工具提示出现之间的时间长度(以毫秒为单位)。0 = 即时。

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.ShowDuration- 当鼠标悬停在工具提示上时,以毫秒为单位的时间长度。将其设置得非常高将有效地成为“永不关闭”选项,但没有真正的始终选项。

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

ToolTipService.BetweenShowDelay- 一旦弹出工具提示,这InitialShowDelay是再次观察之前必须经过的时间量。

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.

这样,当您将鼠标悬停在 TextBox 上时,将在五秒钟后显示一个工具提示。它会停留两秒钟。在您 10 秒内没有查看工具提示之前,悬停和弹出之间不会有任何延迟。

回答by Ebru Güng?r

If you just set ToolTip="Message". Your message will be shown only when the mouse is on the control.

如果您只是设置 ToolTip="Message"。仅当鼠标位于控件上时才会显示您的消息。