设置 IsManipulationEnabled 时,WPF 控件不捕获按住事件(右键单击)
我开始使用触摸屏进行一些测试,我发现如果 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());
}
I'm starting to make some tests with a touch screen and I've found that if a UIControl has the "IsManipulationEnabled" attribute set to true then the MouseRightClick Events fired by the press and hold gesture (WIN7) is not captured. Am I doing something wrong?
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());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
设置 IsManipulationEnabled = true; 后,所有触摸事件均由 WC_Rectangle 捕获并处理,并将它们转换为 Manipulation 事件。因此,触摸事件不会返回到引发它们的控件,这又意味着该控件无法将未处理的触摸事件提升为鼠标事件(默认)。请参阅:
http://nui.joshland .org/2010/04/why-wont-wpf-controls-work-with-touch.html
After setting
IsManipulationEnabled = true;
all touchevents are captured and handled by the WC_Rectangle which does transform them to Manipulation events. So the touchevents do not tunnel back to the control that raised them which in turn means the control can't promote unhandled touch events to mouse events (the default). see:http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html
如果取消操作事件,您应该获得鼠标事件。
If you cancel the manipulation events you should get the mouse events.
使用行为代替
Use Behavior Instead