Manage gestures in ViewModel

I am browsing the web where you will find examples of how to handle flick gestures on Windows Phone 7 in ViewModel using MVVM Light.

I found some good resources when processing commands from button clicks, etc., but I can not find anything about how to handle gestures. Does anyone know if this is possible? If so, are there any good resources or can you give a quick example of how this can be done?

If not, I think I just need to break and put the code in the code. Fu, it makes me hurt to think about it.;)

+4
source share
2 answers

You can use GestureListenerEx Wp7Tools .

Add Wp7Tools to your project:

PM> install-package wp7tools 

In your xaml:

 <Rectangle Fill="Red" Width="100" Height="100"> <toolkit:GestureService.GestureListener> <wp7:GestureListenerEx OnTapAction="Tap" OnDragStartedAction="DragStart" OnDragCompletedAction="DragEnd" /> </toolkit:GestureService.GestureListener> </Rectangle> 

And in your ViewModel:

 public void Tap(GestureEventArgs e) { //Do something } public void DragStart(DragStartedGestureEventArgs e) { Debug.WriteLine(e.Direction); } public void DragEnd(DragCompletedGestureEventArgs e) { Debug.WriteLine(e.Direction); } 

What is it. No code, no commands, just specify the method you want to execute :)

+3
source

How to make the control set that you want to apply gestures to a user control?

Or even wrap a user control around a gesture listener and then surface properties using dependency properties so that you can snap to them.

0
source

Source: https://habr.com/ru/post/1345974/


All Articles