MR.Gestures 1.3.3 » Developer.Team

MR.Gestures 1.3.3

MR.Gestures 1.3.3
MR.Gestures 1.3.3 | 106 kB


Xamarin Forms is great if you want to develop apps for different mobile platforms, but it is missing a critical functionality which every device with a touch screen needs. It cannot handle the various touch gestures. MR.Gestures adds Down, Up, Tapping, Tapped, DoupleTapped, LongPressing, LongPressed, Panning, Panned, Swiped, Pinching, Pinched, Rotating and Rotated events to each and every layout, cell and view and to the ContentPage. These events will be raised when the user performs the corresponding touch gesture on the element. In the EventArgs passed to the handlers you can see exactly what happened.

Event Handlers in XAML
To add the event handler in XAML you have to:
Add the namespace MR.Gestures from the dll
Use the element from that namespace instead of Xamarin.Forms
Add the handlers for the gestures you want to listen to

Commands in XAML
But IMHO if you want to write clean MVVM, then the view should be in XAML and the code behind empty. So instead of the event handlers you can also use commands in your view model and bind them to the respective properties.

The properties for the commands are called like the events, just with Command appended. You can also define a parameter passed to the command with the ..CommandParameter properties. If you suppress the CommandParameter, then the respective event args are passed to your command. In this case a MR.Gestures.LongPressEventArgs object.

For the Tapped, DoubleTapped and LongPressed events you may not need the event args and defining a CommandParameter could make sense. But for the more complicated events you will always need the event args or you won't know what happened. E.g. it does not help to just know that an element has been swiped unless you also know in which direction. The Direction is contained in the SwipeEventArgs.

[/b]

[b] Only for V.I.P
Warning! You are not allowed to view this text.
SiteLock