How can I implement a hold and delete gesture in UWP?
I implemented two VisualStates (NormalState, RemoveState) when I detect that the user is holding my control, I just go to the RemoveState where the delete button will become visible. I want to know how can I get back to NormalState after the user taps outside of my control. I want to do something similar to iOS when deleting an app. User should be able to tap and hold on an item until the delete button appear then when the user decides not to delete it, the user will just tap anywhere outside the control then the delete button will disappear.
Create your own popup with hide/show logic can be tricky 'cause you will need to somehow show an invisible overlay between your popup and the content underneath, subscribe to its Tapped
event and do your dimiss logic there.
I'd suggest to use a built-in MenuFlyout
which already does this for you.
<YourControl>
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Delete"/>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
</YourControl>
Also, you might want to consider subscribing to RightTapped
event instead of Holding
if you want it to work with a mouse.