Title is fairly self-explanitory, I'm working on a Microsoft Surface application, and I don't know what the difference is between these two event handler sets beyond that the PreviewContact(Changed/Down/etc) set works and Contact(Changed/Down/etc) set often doesn't. Is the "Preview" set merely an update for the "regular" set, or does it have something to do with how the event is being fired?
In WPF - which the Surface SDK is built upon - a Routed Event has three routing strategies:
- Bubble
- Tunnel
- Direct
An event with a Bubble strategy will 'Bubble' up the visual tree from the event source to the root of the visual tree (SurfaceWindow) until it either reaches the root of the visual tree or is handled. Conversely, an event with the Tunnel strategy will drill down the visual tree starting at the root until it reaches the event source. Contact events will use both strategies, the Preview events (e.g.PreviewContactDown) use a tunneling strategy while the non-preview events (e.g. ContactDown) will use a Bubble strategy.
If ContactDown is not working then likely the event is being handled somewhere between the root of the visual tree and the event source.
For more information about Routed Events in WPF (this information also applies to Surface) I suggest reading Brian Noyes article Understanding Routed Events and Commands In WPF