WPF 4 多点触控拖放

发布于 2024-09-08 07:04:06 字数 1120 浏览 4 评论 0原文

我有一个 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 似乎认为我的两根手指正在尝试缩放(如捏合手势)...

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

多谢 标记

I have a WPF 4 application where I have implemented Drag and Drop using the standard DragDrop.DoDragDrop approach, but Im doing it using touch instead of Mouse events.

My XAML for my Grid (that Im dragging) is as follows:

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

Now the code behind is like this:

    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
    }

BUT when I try to drag with one finger while already dragging with another finger (different hands for example, which would simulate two people) the second touches don't seem to register properly, infact, it seems that windows thinks that my two fingers are trying to scale (like a pinch gesture)...

Does anyone know a way to get around this?

Thanks a lot
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

假扮的天使 2024-09-15 07:04:06

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

For multi-touch, you're going to want to use the Surface Toolkit for Windows Touch. It includes a drag-and-drop framework suitable for multi-touch scenarios. It includes a drag-and-drop framework. That link includes several how-to scenarios.

橙幽之幻 2024-09-15 07:04:06

尽管这只是一个有根据的猜测,但我想说 DragDrop.DoDragDrop() 无法并行处理多个拖动手势。

索引:

  • 无法将触摸 ID 传递给方法(这对于区分正在进行的拖动手势是必要的)
  • DoDragDrop() 的实现是静态的
  • DoDragDrop()< 的调用/code> 一直阻塞,直到放置发生或被取消
  • 它基于拖放的 OLE 版本(Win7 没有更新)

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

问候,

Although this is just an educated guess, I would say that DragDrop.DoDragDrop() is not capable to handle multiple drag guestures in parallel.

Indices:

  • There's no possibility to pass a touch ID to the method (which would be neccessary for differentiating the ongoing drag gestures)
  • The implementation of DoDragDrop() is static
  • The call of DoDragDrop() is blocking until the drop occured or was canceled
  • It is based upon the OLE version of drag and drop (which was not updated for Win7)

However, I would be glad if someone could correct me in this matter, because I'm currently also searching an DND API suitable for touch support.

Regards,
Seven

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