本文介绍了有没有一种简单的方法来处理 WPF4 中的 Flick 等触摸事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 Windows 7 触摸应用程序,并希望能够将触摸手势作为简单事件处理,特别是轻弹.我可以看到窗口有响应,它会在我轻弹时弹出图标,但我似乎找不到一种简单的方法来处理它们.类似于 grid.OnLeftFlick ...

I'm building a windows 7 touch app and want to be able to handle touch gestures as simple events, specifically flicks. I can see windows responding, it pops up the icons as I flick but I can't seem to find an easy way to handle them. Something like grid.OnLeftFlick ...

我错过了一些愚蠢的简单事情吗?有工具包或我可以使用的东西吗?或者,我必须编写自己的监听器吗?

Am I missing something stupidly simple? Is there a toolkit or something I can use? Or, do I have to write my own listener?

谢谢.

推荐答案

虽然 WPF4 确实支持多点触控,但它没有任何内置的手势支持,至少不是您所想的那种.轻弹、捏合缩放等功能都必须在 WPF4 之上进行编程.

While WPF4 does support multi-touch, it does not have any built in gesture support, at least not of the kind you are thinking about. Features such as flick, pinch-zoom, etc. all have to be programmed on top of WPF4.

我不知道任何更高级别的手势支持工具包,但编写自己的工具包并不像听起来那么难.此 WPF4 触摸示例展示了基于触摸的移动、捏合缩放和捏合旋转:

I don't know of any higher-level gesture support toolkits but writing your own is not as hard as it sounds. This WPF4 touch sample shows for example touch based move, pinch-zoom and pinch-rotate:

如果您编译并运行该示例,您会发现处理程序只有 10 到 20 行代码,并利用了触摸 API 本身的强大基础设施和核心 WPF 功能,例如转换矩阵.触摸 API 支持惯性等,因此请尝试满足您需求的轻弹.

If you compile and run the sample you'll see the handlers are only ten to twenty lines of code and make use of powerful infrastructure in the touch API itself and core WPF features such as transformation matrices. The touch API supports inertia, etc. so try your hand at a flick that meets your needs.

当然,此示例仅适用于笔和触控输入设备,而不是普通鼠标,但您指定您正在开发触控应用程序.

Also, of course, this sample only works with Pen and Touch input devices, not an ordinary mouse, but you specified that your are developing a touch application.

这篇关于有没有一种简单的方法来处理 WPF4 中的 Flick 等触摸事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 01:15