5

我有一个 WPF 4 应用程序,我在其中使用标准方法实现了拖放DragDrop.DoDragDrop,但我使用触摸而不是鼠标事件来实现。

我的网格(我拖动)的 XAML 如下:

<Grid x:Name="LayoutRoot" 
      ManipulationStarting="ManipulationStarting" 
      ManipulationDelta="ManipulationDelta" 
      ManipulationCompleted="ManipulationCompleted"
      IsManipulationEnabled="True">
    <!-- children in here -->
</Grid>

现在后面的代码是这样的:

    private void ManipulationStarting(object sender, ManipulationStartingEventArgs e)
    {
        e.ManipulationContainer = this;
        e.Handled = true;
    }

    private void ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        e.Handled = true;
        DragDrop.DoDragDrop(this, new DataObject(GetType(), this), DragDropEffects.Move);
    }

    private void ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
    {
        //completed stuff
    }

但是当我尝试用一​​根手指拖动而已经用另一根手指拖动时(例如不同的手,这将模拟两个人),第二次触摸似乎没有正确注册,事实上,Windows 似乎认为我的两根手指是试图缩放(像捏手势)......

有谁知道解决这个问题的方法?

非常感谢马克

4

2 回答 2

4

对于多点触控,您将需要使用 Surface Toolkit for Windows Touch。它包括一个适用于多点触控场景的拖放框架。它包括一个拖放框架。该链接包括几个操作方法场景。

于 2010-08-29T19:25:08.567 回答
1

虽然这只是一个有根据的猜测,但我会说它DragDrop.DoDragDrop()不能同时处理多个拖动客体。

指数:

  • 不可能将触摸 ID 传递给该方法(这对于区分正在进行的拖动手势是必要的)
  • 的实现DoDragDrop()是静态的
  • 的调用DoDragDrop()被阻塞,直到丢弃发生或被取消
  • 它基于 OLE 版本的拖放(未针对 Win7 进行更新)

但是,如果有人能在这件事上纠正我,我会很高兴,因为我目前也在搜索适合触摸支持的 DND API。

问候,七

于 2010-08-12T12:55:22.473 回答