【问题标题】:WPF control does not capture the press and hold event (right click) when IsManipulationEnabled is set设置 IsManipulationEnabled 时,WPF 控件不捕获按住事件(右键单击)
【发布时间】:2010-06-21 14:18:47
【问题描述】:

我开始使用触摸屏进行一些测试,我发现如果 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());
    }

【问题讨论】:

    标签: wpf events touchscreen right-click


    【解决方案1】:

    在设置IsManipulationEnabled = true; 之后,所有的触摸事件都被 WC_Rectangle 捕获和处理,WC_Rectangle 将它们转换为操作事件。因此,触摸事件不会返回到引发它们的控件,这反过来意味着控件不能将未处理的触摸事件提升为鼠标事件(默认值)。见:

    http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html

    【讨论】:

      【解决方案2】:

      如果你取消操作事件,你应该得到鼠标事件。

      【讨论】:

        【解决方案3】:

        改用行为

        【讨论】:

          猜你喜欢
          • 2013-06-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-05-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多