如何让tooltip随着鼠标移动?
我正在使用 Silverlight 3 + VSTS 2008。我有一个图像(多尺度图像控件),我在该图像上放置了工具提示。 Tooltip的功能很好用。由于图像很大(大约500 * 500大小),并且由于最终用户可以在图片上移动鼠标,并且我想随着鼠标一起显示工具提示位置(即当鼠标移动时,我希望工具提示随着鼠标移动)。目前,工具提示显示在固定位置。
这是我当前的 XAML 代码,有什么想法如何解决这个问题吗?
<MultiScaleImage x:Name="msi" Height="500" Width="500">
<ToolTipService.ToolTip>
<ToolTip Content="Here is a tool tip" Name="DeepZoomToolTip"></ToolTip>
</ToolTipService.ToolTip>
</MultiScaleImage>
I am using Silverlight 3 + VSTS 2008. I have a image (Multiscale image control) and I place tooltip on this image. The function of Tooltip works fine. Since the image is big (about 500 * 500 size), and since end user could move mouse on the picture, and I want to display tooltip position along with the mouse (i.e. when mouse moves, I want to tooltip move along with the mouse). Currently, the tooltip displays at a fixed position.
Here is my current XAML code, any ideas how to solve this issue?
<MultiScaleImage x:Name="msi" Height="500" Width="500">
<ToolTipService.ToolTip>
<ToolTip Content="Here is a tool tip" Name="DeepZoomToolTip"></ToolTip>
</ToolTipService.ToolTip>
</MultiScaleImage>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终遇到了类似的问题,并通过使用弹出窗口解决了该问题。 这篇文章包含核心解决方案。这是另一篇文章中建议的 XAML:
这是建议的,这将放在后面的代码中:
I ended up having a similar issue and solved the issue by using a popup. This post contained the core solution. Here is the suggested XAML from the other post:
And here is the suggested, this would go in the code behind:
工具提示控件设计为大致在鼠标遇到其绑定元素的位置弹出,并且无法响应移动事件。下面是一个自定义工具提示示例。我添加了背景和 z 索引,以便 TextBlock 出现在图像上。与鼠标位置的偏移使工具提示远离鼠标光标,以便平滑地动画移动。
XAML:
代码:
The tooltip control is designed to pop up roughly where the mouse meets the element to which it's bound, and can't respond to move events. Below is a custom tooltip example. I added the background and the z-index so that the TextBlock would appear over the image. The offset from the mouse position keeps the tooltip away from the mouse cursor, so that the movement is animated smoothly.
XAML:
Code: