i have button in my windows phone silverlight 8.1 app i created two event one click event and second hold event, i want when user hold such button then click event should not fire, but currently when i hold button and then leave that button click button also fires, so how to handle that.
private void ExtraButton_Click(object sender, RoutedEventArgs e)
{
}
private void ExtraButton_Hold(object sender, GestureEventArgs e)
{
}
so how to cancel click event when hold event performed.
Use Button_Hold and Button_Tap events to achieve your requirement.
You can achieve your requirement by unwire the button click event while holding and again wire the click event in PointerExited event. Refer the below code snippet.
In PointerExited event, you can hook the click event only if it is not already hooked using some conditions. It will improve the performance.
I suggest you can replace the Button Click event with Button Tap event, because when you hold this button, the Button Hold event will be triggered firstly.
After you set Handled property as true, then the Button Click event will not handle your gesture.