Forum Xamarin Xamarin.Forms

Long Press Gesture

VelocityVelocity NZMember ✭✭✭


Following on from the Swipe Gesture proposal, would like to propose that a long-press recognizer be added to Xamarin.Forms.

API Changes

Same basic API design and commanding as the existing TapGestureRecognizer and Pan/Pinch recognizers.
Two new bindable properties:

    /// <summary>
    /// Gets or sets the maximum movement in pixels before the gesture is canceled.
    /// </summary>
    public int AllowableMovement
        get { return (int)GetValue(AllowableMovementProperty); }
        set { SetValue(AllowableMovementProperty, value); }

    /// <summary>
    /// Gets or sets the minimum press duration in milliseconds.
    /// </summary>
    public int MinimumPressDuration
        get { return (int)GetValue(MinimumPressDurationProperty); }
        set { SetValue(MinimumPressDurationProperty, value); }

Intended Use Case

Contextual actions on views e.g. long press for context menu, delete etc.
On desktop platforms with a mouse, long-press could optionally be resolved to respond to a right-mouse click.

We have already built a custom long-press recognizer which is production-grade and working across iOS, Android and UWP.
Happy to implement if accepted.


Open · Last Updated


  • DavidDancyDavidDancy AUMember ✭✭✭✭

    I would suggest using something other than pixels for the movement sensor as there are too many different screen sizes with different pixels densities. I'd prefer to see this new API use the same units as Xamarin Forms does.

    Otherwise, like it very much.

  • mdizzymdizzy USMember ✭✭

    Is there a branch for this already? I've been working with gestures and could help implement this.

  • VelocityVelocity NZMember ✭✭✭
    @DavidDancy @mdizzy Thanks for the suggestions.
    Yes, have already built this on all three platforms and shipped it. If approved, can put a PR up fairly quickly.

    Would be great to get feedback though and work along with others to improve etc. If approved, can put a branch up.

    Just waiting on approval for the SwipeGestureRecognief first.
  • RyanFrenchRyanFrench USMember ✭✭

    Yes this is very much needed. Does anyone know a way to achieve this without a custom renderer and without that MR gestures library?

  • VelocityVelocity NZMember ✭✭✭
    You don't actually require a custom renderer, rather you simply need to create your own custom gesture recognizer and write the native implementation on each platform.
  • Nor0xNor0x USMember ✭✭

    Any updates on this topic? Is it already approved? I'm looking for a way to implement Long Press in a ListView

  • wend0rlinwend0rlin DEMember ✭✭

    @Nor0x said:
    Any updates on this topic? Is it already approved? I'm looking for a way to implement Long Press in a ListView

    jep, same here!

Sign In or Register to comment.