Skip to content

[Enhancement] Add LongPressGestureRecognizer #8675

Closed

Description

@MissedSte4k

Description

The GestureRecognizers are lacking. Can we add LongPressGestureRecognizer to aid with more possibilities of choices/options in UI? LongPressGestureRecognizer already works in xamarin and I think would be a great and necessary addition in MAUI.

Public API Changes

Copy paste from xamarin proposal

public class LongPressGestureRecognizer : GestureRecognizer
{
	public static readonly BindableProperty IsLongPressingProperty;
	public bool IsLongPressing { get; set; }

	public ICommand FinishedCommand { get; set; }
	public object FinishedCommandParameter { get; set; }
	
	// Bindable Property will live on GestureRecognizer
	public ICommand CancelledCommand { get; set; }
	public object CancelledCommandParameter { get; set; }
	
	// Bindable Property will live on GestureRecognizer
	public ICommand StartedCommand { get; set; }
	public object StartedCommandParameter { get; set; }
	
	public static readonly BindableProperty NumberOfTouchesRequiredProperty;
	public int NumberOfTouchesRequired { get; set;}

	public static readonly BindableProperty NumberOfTapsRequiredProperty;
	public int NumberOfTapsRequired { get; set; }

	public static readonly BindableProperty MinimumPressDurationProperty;
	public double MinimumPressDuration { get; set; }

	public static readonly BindableProperty AllowableMovementProperty;
	public uint AllowableMovement { get; set; }

	public event EventHandler LongPressed;
	public event EventHandler<LongPressUpdatedEventArgs> LongPressUpdated;
}

Intended Use-Case

Used in xaml to add gestures to the UI. Example:

<Frame.GestureRecognizers>
    <TapGestureRecognizer Command="{Binding Path=BindingContext.OpenEventCommand, Source={x:Reference Name=Main}}" CommandParameter="{Binding}" NumberOfTapsRequired="2" />
    <LongPressGestureRecognizer Command="{Binding Path=BindingContext.OpenMenuCommand, Source={x:Reference Name=Main}}" CommandParameter="{Binding}" />
</Frame.GestureRecognizers>

In this case, we could do more things based on the gestures

Activity

  1. added
    area-xaml
    on Jul 12, 2022
  2. added this to the Backlog milestone on Aug 2, 2022
  3. v-croft commented on Sep 3, 2022

    @v-croft

    Please could this feature be added?

  4. Juansero29 commented on Dec 15, 2022

    @Juansero29

    Seems like CommunityToolkit will implement this feature, can be tracked with this issue: CommunityToolkit/Maui#86

  5. removed
    good first issue
    on Jun 19, 2023
  6. added
    area-gestures
    and removed
    area-xaml
    on Jul 12, 2023
  7. 11 remaining items

  8. jfversluis commented on Mar 17, 2026

    @jfversluis
    Member

    Implemented for .NET 11 in #33432. Will be released as part of .NET 11 preview 3. Please try it out early and provide us with the feedback so we can make sure it's solid by GA in November. Thanks!

  9. jeremy-visionaid commented on Mar 25, 2026

    @jeremy-visionaid
    Contributor

    @jfversluis Thanks for this! I implemented my own some time ago and found that there were various upstream problems preventing multi-contact long press from working in WinUI:
    microsoft/microsoft-ui-xaml#10687
    microsoft/microsoft-ui-xaml#10924

    Maybe you have some clout to poke people at MS for getting those things fixed and then we could bring the Windows one up to parity with the others?

  10. jfversluis commented on Mar 25, 2026

    @jfversluis
    Member

    @jeremy-visionaid Thanks! Please test this early if you can and let us know so we can improve before GA and it's as solid as possible :)

    For the Windows issues, I'll see what I can do. I can imagine touch is less of a priority to them.

  11. locked and limited conversation to collaborators on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions