以编程方式设置工具提示持续时间的问题
我遇到过一种情况,我需要创建一个工具提示对象并在用户将鼠标悬停在应用程序中的特定区域上时显示它。
我可以让工具提示正常显示。问题是我需要它在几秒钟后消失。我知道 ToolTipService.SetShowDuration
并尝试使用它,但我没有遇到太多运气。
这是我在 MouseMove 事件处理程序中得到的内容:
_toolTip.Placement = PlacementMode.Relative;
_toolTip.Horizontal = e.X;
_toolTip.VerticalOffset = e.Y;
_toolTip.Content = stuffs;
_toolTip.IsOpen = true;
我尝试设置以下内容:
someObject.ToolTip = _toolTip;
ToolTipService.SetShowDuration(someObject, 5);
最后两行没有任何变化。工具提示仍然可见并且保持可见。我使用该服务的方式有误吗?任何想法将不胜感激!
I've come across a situtation where I need to create a tooltip object and show it when the user hovers over specific areas in my application.
I can get the tooltip to show up just fine. The problem is I need it to go poof after a few seconds have passed. I'm aware of the ToolTipService.SetShowDuration
and I've tried using it, but I have not been met with much luck.
Here's what I got in my MouseMove event handler:
_toolTip.Placement = PlacementMode.Relative;
_toolTip.Horizontal = e.X;
_toolTip.VerticalOffset = e.Y;
_toolTip.Content = stuffs;
_toolTip.IsOpen = true;
I've tried setting the following:
someObject.ToolTip = _toolTip;
ToolTipService.SetShowDuration(someObject, 5);
Nothing changes with the last two lines. The tooltip still is visible and stays visible. Am I using the service wrong or something? Any thoughts would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我为这个问题开发了一个解决方法。
为了提供更多背景信息,我在 WindowsFormsHost 对象内有一个飞机的 3D 模型。当用户将鼠标悬停在已识别的部分上时,我需要出现一个工具提示。
我创建了一个工具提示实例,并在 MouseMove 事件中执行了如下操作:
这对我来说很有效。
I developed a workaround for the issue.
To give a little more background, I have a 3D model of an aircraft inside of a WindowsFormsHost object. When the user hovers over a identified part, I needed a tooltip to appear.
I created an instance of tooltip and in my MouseMove event and I do something like this:
That does the trick for me.
试试这个。
Try this.