Long Press Button on MAUI Android

Tony Pitman 116 Reputation points
2025-10-18T23:49:50.1533333+00:00

I am writing a MAUI mobile app for iOS and Android.

I need to be able to detect when the user holds down a button so I can repeats its action.

I had it working fine on iOS with pressed and released gestures, but it wouldn't work on Android emulator. I don't have an Android phone to test on, so I am not sure whether it will work on Android at all.

Does anyone have some code or a nuget that will allow me to have a press and hold button on MAUI that works on iOS and Android?

Developer technologies | XAML
Developer technologies | XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Tony Dinh (WICLOUD CORPORATION) 3,585 Reputation points Microsoft External Staff
    2025-10-20T07:18:22.6866667+00:00

    Hello @Tony Pitman !

    You can achieve a press-and-hold button in .NET MAUI that works on both iOS and Android by using the .NET MAUI Community Toolkit’s TouchBehavior. This provides a cross-platform way to detect long presses and repeat actions, without relying on platform-specific gesture quirks. You can refer to this documentation here https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/touch-behavior?tabs=toucheffect-xaml%2Ctouchbehavior-xaml.

    There are included examples have been done for you!


    I hope this helps! If you agree with my suggestion! Please mark this as final answer, thank you!


0 additional answers

Sort by: Most helpful

Your answer