I think I have a not so complicated problem, but I can't solve it or find the solution on internet.
我认为我有一个不那么复杂的问题,但我无法解决它或在互联网上找到解决方案。
I have some random RichTextBox
我有一些随机的RichTextBox
<RichTextBox x:Name="myRichTextBox" ToolTipOpening="RichTextBoxEx1_ToolTipOpening" ToolTip=" "></RichTextBox>
I want to show a specific Tooltip depending on the word hovered by the mouse. I already have a solution for this.
我想显示一个特定的工具提示,取决于鼠标悬停的单词。我已经有了解决方案。
Let's said that my RichTextBox have a text like this "My house is green". If I hover over the word 'green', it shows the Tooltip OK, but if I need to show the Tooltip over the word 'house' I need to get out my mouse of the RichTextBox control and enter again.
让我们说我的RichTextBox有一个像这样的文字“我的房子是绿色的”。如果我将鼠标悬停在“绿色”一词上,它会显示工具提示确定,但如果我需要在“房子”一词上显示工具提示,我需要取出RichTextBox控件的鼠标并再次输入。
So, I'm asking for some 'reset' of the tooltip. Something like, when I move my mouse, the current Tooltip disappears and I dont need to wait for a new Tooltip without take out my mouse of the control.
所以,我要求对工具提示进行一些“重置”。有点像,当我移动我的鼠标时,当前的工具提示消失了,我不需要等待新的工具提示而不取出我的鼠标控件。
Thank you so much.
非常感谢。
1 个解决方案
#1
0
I usually just set ToolTip
property to null
and assign a new ToolTip
object:
我通常只将ToolTip属性设置为null并分配一个新的ToolTip对象:
element.ToolTip = null;
var tooltip = new ToolTip();
tooltip.Content = ...
element.ToolTip = tooltip;
tooltip.IsOpen = true;
tooltip.StaysOpen = false;
Now to call this code, you will have to implement some kind of hover mechanism based on MouseMove
event and preferably a timer - it's not included in WPF.
现在要调用此代码,您必须实现某种基于MouseMove事件的悬停机制,最好是一个计时器 - 它不包含在WPF中。
#1
0
I usually just set ToolTip
property to null
and assign a new ToolTip
object:
我通常只将ToolTip属性设置为null并分配一个新的ToolTip对象:
element.ToolTip = null;
var tooltip = new ToolTip();
tooltip.Content = ...
element.ToolTip = tooltip;
tooltip.IsOpen = true;
tooltip.StaysOpen = false;
Now to call this code, you will have to implement some kind of hover mechanism based on MouseMove
event and preferably a timer - it's not included in WPF.
现在要调用此代码,您必须实现某种基于MouseMove事件的悬停机制,最好是一个计时器 - 它不包含在WPF中。