设置 IsManipulationEnabled 时,WPF 控件不捕获按住事件(右键单击)

发布于 2024-09-06 03:09:11 字数 540 浏览 1 评论 0原文

我开始使用触摸屏进行一些测试,我发现如果 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

二手情话 2024-09-13 03:09:11

设置 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

天煞孤星 2024-09-13 03:09:11

如果取消操作事件,您应该获得鼠标事件。

If you cancel the manipulation events you should get the mouse events.

捶死心动 2024-09-13 03:09:11

使用行为代替

Use Behavior Instead

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文