Is there a simple way to handle Touch events like Flick in WPF4?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-10 03:09:25

问题


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?

Thanks.


回答1:


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.

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:

  • Walkthrough: Creating Your First Touch Application

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.



来源:https://stackoverflow.com/questions/6104668/is-there-a-simple-way-to-handle-touch-events-like-flick-in-wpf4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!