我开始使用触摸屏进行一些测试,我发现如果 UIControl 的“IsManipulationEnabled”属性设置为 true,则不会捕获按住手势(WIN7)触发的 MouseRightClick 事件。难道我做错了什么?
public MainWindow()
{
InitializeComponent();
WC_Rectangle.IsManipulationEnabled = true;
WC_Rectangle.MouseRightButtonUp += new MouseButtonEventHandler(WC_Rectangle_MouseRightButtonUp);
}
void WC_Rectangle_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Debug.WriteLine("RIGHT CLICK : " + sender.ToString());
}
最佳答案
设置后IsManipulationEnabled = true;
所有触摸事件都由 WC_Rectangle 捕获和处理,WC_Rectangle 会将它们转换为 Manipulation 事件。因此,触摸事件不会返回到引发它们的控件,这反过来意味着控件无法将未处理的触摸事件提升为鼠标事件(默认)。看:
http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html
关于设置 IsManipulationEnabled 时,WPF 控件不捕获按住事件(右键单击),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3085431/