检查鼠标在 Silverlight 的 MouseLeave 事件中进入哪个 UIElement?
我有两个彼此相邻的 UIElement
,我希望它们表现得好像它们是一个 MouseLeave
区域。
如何检查鼠标是否位于 MouseLeave
事件期间输入的 UIElement
上?
目前,使用以下解决方案检查鼠标位置会显示鼠标在 MouseLeave
事件期间离开的元素上:http://forums.silverlight.net/forums/p/193378/448518.aspx。
谢谢。
I have two UIElement
s next to each other that I want to behave as if they are one MouseLeave
area.
How can I check if the mouse is over a UIElement
being entered during a MouseLeave
event?
Currently, checking the mouse position using the following solution shows the mouse over the element being left during the MouseLeave
event: http://forums.silverlight.net/forums/p/193378/448518.aspx.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道事件顺序是否是确定性的,所以我不知道您是否可以准确地执行您所描述的操作。你也许可以用一些奇怪的代码来做到这一点。例如,您可以尝试创建一个 UI 元素命中测试函数,并在鼠标离开事件处理程序期间检查它。这不会是非常灵活的代码。
我还没有尝试过这个,但您可能可以通过将两个 UI 元素包含在父元素(例如网格)中并将事件处理程序添加到该父元素来解决此问题。那会更简单,也更灵活。
I don't know if the event order is deterministic, so I don't know if you can do exactly what you are describing. You might be able to do it with some weird code. For example, you could try making a UI element hit-test function, and checking it during the mouse leave event handler. This would not be very flexible code.
I haven't tried this, but you could probably solve this problem by containing both UI elements in a parent element, such as a grid, and adding your event handlers to that parent. That would be much simpler, and much more flexible.