WPF拖动距离阈值 [英] WPF drag distance threshold
本文介绍了WPF拖动距离阈值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有两个WPF树视图的程序,允许在两个WPF树视图之间进行拖放。问题是,打开/关闭树视图上的项目可能很烦人,因为在按住鼠标左键的同时仅移动鼠标一个像素会触发拖放功能。有什么方法可以指定鼠标在被拖放之前应该移动多远?
I have a program with two WPF treeviews that allow dragging and dropping between the two. The problem is, it can be annoying to open / close items on the treeviews because moving the mouse just one pixel while holding the left mouse button triggers the drag / drop functionality. Is there some way to specify how far the mouse should move before it's considered a drag / drop?
推荐答案
有一个系统参数这个。如果您有
There's a system parameter for this. If you have
Point down = {where mouse down event happened}
Point current = {position in the MouseMove eventargs}
然后,如果
Math.Abs(current.X - down.X) >= SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(current.Y - down.Y) >= SystemParameters.MinimumVerticalDragDistance)
这篇关于WPF拖动距离阈值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文