Wpf 拇指拖动不会在其他组件上触发拖动输入
我有一个带有一些 Thumb 控件的 wpf 应用程序,这些控件可以在画布上移动项目。我想检测这些拇指何时被拖动到另一个元素上。但是,不会触发被拖过的元素上的拖动输入。我知道这段代码的作用是拖动项目而不是拇指触发事件。
拇指上的拖动事件不是其他组件监听的拖动事件吗?
知道如何让它发挥作用吗?
I have a wpf application with some Thumb controls which move items around a canvs. I want to detect when these thumbs are dragged over another element. However, the drag enter on the element which is dragged over is not fired. I know this code works as drag items that are not thumbs fire the event.
Is the drag event on the thumb not a drag event that other components listen to?
Any idea how to get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然没有。唯一与 Thumb 相关的事件是 DragStarted、DragCompleted 和 DragDelta。其他事件用于拖放,例如 DragEnter 事件。这些事件特别适用于拖放操作,例如将文件从资源管理器拖到应用程序中,与 Thumb 无关。名称相似但实际上却截然不同。
您可以尝试的一件事是在拖动时使用 HitTesting,但请记住,拖放和拖动拇指会捕获鼠标,这会禁用其他类上的输入事件。
Apparently no. The only Thumb related Events are DragStarted, DragCompleted and DragDelta. The other events are for Drag and drop, like your DragEnter Event. These Events are especially for the Drag and drop, like dragging a file from the explorer into your application which has nothing to do with the Thumb. The names are similar but in fact very different.
One thing you could try is to use HitTesting while dragging, but remember that drag and drop and dragging a thumb takes the mouse capture, which disables input events on the other classes.
为了在拇指对象移动到另一个组件上时模拟拖动输入事件,我必须执行以下操作:
为拇指拖动增量注册事件处理程序
然后在事件处理程序中查看拖动的元素是否位于所拖动的元素上方监听移动组件
记住稍后删除事件处理程序等。
希望这对将来的人有帮助。
To achieve the simulation of a drag enter event when a thumb object is moved over another component I've had to do this:
Register event handler for the thumb drag delta
Then in the event handler see if the dragged element is over the element that is listening to the moving component
Remember to removed event handlers etc later.
Hope this helps someone in the future.