DoDragDrop 禁用 MouseMove 事件
开始拖放后通过 DragDrop.DoDragDrop(...) 进行的放置操作不再触发 MouseMove 事件。我什至尝试了
AddHandler(Window.MouseMoveEvent, new MouseEventHandler(myControl_MouseMove), true);
最后一个参数意味着我什至选择加入已处理的事件。没有机会,似乎 MouseMove 事件根本就没有被触发过!使用 Drag & 时仍然获得 MouseMove 事件的任何方法降低?我想拖放放下一个控件,在拖动该控件时,它将跟随鼠标指针移动。知道在这种情况下该怎么做吗?
After having started a Drag & Drop operation by DragDrop.DoDragDrop(...) no more MouseMove Events are fired. I even tried
AddHandler(Window.MouseMoveEvent, new MouseEventHandler(myControl_MouseMove), true);
where the last parameter means I even opt in for handled events. No chance, seems like the MouseMove Event is never fired at all! Any way to still get MouseMove Events while using Drag & Drop? I'd like to Drag & Drop a control, while dragging this control it shall follow the mouse pointer. Any idea how to do this in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要处理
DragOver
事件。编辑:尝试处理<您调用
DoDragDrop
的控件上的 code>GiveFeedback 事件;这可能会满足您的需求。You need to handle the
DragOver
event.EDIT: Try handling the
GiveFeedback
event on the control that you calledDoDragDrop
on; that might do what you're looking for.什么是 DragDrop.DoDragDrop 构造? DoDragDrop 实际上是在 MouseDown/MouseMove 方法中调用的,而不是在 DragDrop 中调用的。它应该开始处理该过程,而不是对放置做出反应(您直接在 DragDrop 中直接实现的放置的所需效果)。 MouseMove 在拖动时永远不会触发,也许这就是为什么它不会随您一起触发,因为您设置了过程。我认为你处理这种错误的方式,这是示例之一 http://msdn.microsoft.com/en-us/library/aa984430%28v=vs.71%29.aspx。
What is the DragDrop.DoDragDrop construction? DoDragDrop is intended to be called in MouseDown/MouseMove method indeed, not in DragDrop. It is supposed to START handling the procedure, not to react for the drop (the desired effect of the drop you just implement directly in DragDrop). MouseMove never fires while already dragging, perhaps that's why it does not also fire with you, since you set the procedure. I think you handle this wrong way, here is one of examples http://msdn.microsoft.com/en-us/library/aa984430%28v=vs.71%29.aspx.