Add the nuget package https://www.nuget.org/packages/Vapolia.XamarinFormsGesture/ to all your Xamarin Forms projects (iOS, Android, Share...

XamarinFormsGesture XamarinFormsGesture

XamarinFormsGesture

XamarinFormsGesture

Add the nuget package https://www.nuget.org/packages/Vapolia.XamarinFormsGesture/ to all your Xamarin Forms projects (iOS, Android, Shared/PCL).

In your Android/iOS projects, before initializing Xamarin.Forms, call PlatformGestureEffect.Init() to force the discovery of the gestures by the Xamarin Forms plugin engine. The elements on which the gesture is applied must have the property Enabled="True" and InputTransparent="True" which activates user interaction on them.

Quick start

Xamarin Form Gesture Effects supports iOS and Android.
Add "advanced" gestures to Xamarin Forms. Available on all views. Sample use:
<Label Text="Click here" Style="{StaticResource LinkLabel}" ui:Gesture.TapCommand="{Binding OpenLinkCommand}" />
Add Gesture.TapCommand on any supported xaml view:
<StackLayout ui:Gesture.TapCommand="{Binding OpenLinkCommand}">
    <Label Text="1.Tap this to open an url"  />
</StackLayout>
Declare the corresponding namespace:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         ...
         xmlns:ui="clr-namespace:Vapolia.Lib.Ui;assembly=XamarinFormsGesture"
>
And in the viewmodel add your Command as in below
public Command OpenLinkCommand => new Command(() =>
{ //do something
});

Supported Gestures

  1. TapCommand (ICommand)
  2. TapCommand2 (Command<Point>) where point is the tap position in the view
  3. SwipeLeftCommand
  4. SwipeRightCommand
  5. SwipeTopCommand
  6. SwipeBottomCommand
  7. PanCommand (Command<Point>) where point is the translation in the view from the start point of the pan gesture

Limitations

Only commands are supported and No .NET events. So you must use the MVVM pattern (https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/databindingsto_mvvm/).

0 comments: