Skip to content

A container View for Xamarin.Forms that supports event binding for gestures like Long Press, Tap and Right Click.

License

Notifications You must be signed in to change notification settings

chaosifier/MultiGestureView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiGestureView

Extended ContentView with Events for gestures like Tap, Long Press and Right Click. Also supports Vibration and Vibration duration for haptic feedback.

Setup :

MultiGestureViewRenderer.Init();

The library needs Vibration permission in Android for vibration to work. The permission should automatically be added if installed from NuGet. If the vibration still doesn't work, try adding the Vibration permission explicitly.

Gesture Support :

Platform Long Press Tap Right Click
Xamarin.iOS Unified Yes Yes No
Xamarin.Android Yes Yes No
UWP No Yes Yes

Basic Usage :

  • Code behind
var gestureView = new MultiGestureView()
{
    VibrateOnTap = true,
    TapVibrationDuration = 150,
    VibrateOnLongPress = true,
    LongPressVibrationDuration = 300,
    HeightRequest = 300,
    WidthRequest = 300,
    BackgroundColor = Color.Salmon,
    HorizontalOptions = LayoutOptions.Center,
    VerticalOptions = LayoutOptions.Center,
    Content = new Label() { Text = "Hello World!", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }
};

gestureView.Tapped += (s, e) =>
{
    DisplayAlert("Tapped", "Tap gesture detected.", "Ok");
};

gestureView.LongPressed += (s, e) =>
{
    DisplayAlert("Long Pressed", "Long press gesture detected.", "Ok");
};

gestureView.RightClicked += (s, e) =>
{
    DisplayAlert("Right Click", "Right click detected.", "Ok");
};
  • XAML
<multigestureviewplugin:MultiGestureView
    x:Name="theMgv"
    Padding="30"
    BackgroundColor="Salmon"
    HeightRequest="200"
    HorizontalOptions="Center"
    LongPressVibrationDuration="1000"
    LongPressedCommand="{Binding MyLongPressedCommand}"
    RightClickedCommand="{Binding MyRightClickedCommand}"
    TapVibrationDuration="500"
    TappedCommand="{Binding MyTappedCommand}"
    TappedCommandParameter="{Binding Source={x:Reference theMgv}}"
    VibrateOnLongPress="True"
    VibrateOnTap="True">
    <Label
        FontSize="Large"
        HorizontalOptions="Center"
        Text="Click / Right-Click / Long Press here"
        TextColor="White"
        VerticalOptions="Center" />
</multigestureviewplugin:MultiGestureView>

About

A container View for Xamarin.Forms that supports event binding for gestures like Long Press, Tap and Right Click.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages