Reputation: 75
So I'm just doing tests to my project, and realized that if you have a link (for example navigation service), it takes both taps and double taps. This means if I have a button that goes to another page within the app, unless I don't handle the double tap, the app will crash.
So if I have this:
<toolkit:HubTile Name="XXX"
Message="XXXYYY" Source="ZZZ"
Title="XYZ" Tap="XYZ_Tap"/>
If anyone double taps this tile, the app will crash. So instead I have to add the
DoubleTap="XYZ_DoubleTap"
property. But this can get both tiring and seems unnecessary. So is there a way to handle ALL double taps globally? Then if I want to actually implement it somewhere, just override it? Thanks :)
Edit: The "Global" event handler for DoubleTap is simple to do nothing. This way I don't have to rewrite it for each link or button. And an exception won't be thrown each time an none handled DoubleTap is called.
Upvotes: 3
Views: 345
Reputation: 15268
You should create a custom Control that inherits from HubTile
and set the DoubleTap
event to do nothing in that class.
Upvotes: 1
Reputation: 2525
The crash is most likely occurring because an exception was thrown on the second "tap". Something along the lines of "Navigation is not allowed when the task is not in the foreground."
I guess putting an empty event handler for DoubleTap will work, as it recognizes the double tap event and does nothing. Another approach, which probably should be done anyway, is to wrap the navigation call in a try/catch block to catch the exception thrown by the second tap.
But to address your specific question, what sort of global handling of a double tap were you envisioning other than doing nothing?
Upvotes: 2