Reputation: 53
I have a basic implementation of a custom render I will be using for handling Long Press.. It's all really based from this code http://arteksoftware.com/gesture-recognizers-with-xamarin-forms/
In my "GestureContainerView" I have an event that I called "OnHeldDown",
How do I raise this "OnHeldDown" event if (in my Android) detected a "LongPress" ?
I tried looking up in google but couldn't find an example.
----------- UPDATE ------- (found a solution)
Upvotes: 0
Views: 2560
Reputation: 33993
Just create a method which checks if anyone is subscribes to the event handler and invoke it, if anyone is.
For example, create a methode like this:
private void RaiseOnHeldDown()
{
if (OnHeldDown != null)
OnHeldDown(this, EventArgs.Empty);
// Or even do the null propagation way
// OnHeldDown?.Invoke(this, EventArgs.Empty);
}
Of course if you'd like you can supply EventArgs
.
Now in the event where you detect the LongPress you just call this method.
Upvotes: 1