formsxamarinbuttonpressed

Xamarin Forms Button pressed event for 3 seconds executes action or nothing


I need to write a event behind a button, when i pressed it for 3 seconds a method must executes. If i released it before the 3 seconds, it doesnt do anything.

Any ideas?

Thanks!


Solution

  • Since Xamarin Forms 2.4, buttons have included Pressed and Released events.

    Start a 3 second timer in the Pressed event. Cancel it in the Released event if it hasn't fired.