I struggled a bit with a Surface event handler named TouchMove. What I expected was to be able to trigger whenever my object was moved by touch. This however, did not trigger it one bit. My frustration/anger was unending since I couldn’t know whether or not this was a bug or just working as intended.
I left the breakpoint in the code and proceeded to hook up LayoutChanged as an alternate event handler to track the same thing (in a better way really). After playing around with LayoutChanged for a while the TouchMove breakpoint suddenly triggered seemingly at random. It turned out that the event handler was working perfectly well but that the hitbox of the object I was dragging didn’t move with the object.
Lessons
- Moving an object in a ScatterView does not move the object, it simply applies a transform to X and Y.
- LayoutUpdated is a great event handler, if you like your event to trigger a LOT
- Never remove old breakpoints
NOTE: These event handlers are the same in WPF/Surface 1.0. This are not new features of Surface2. Not removing breakpoints is copyright Viktor Larsson 2011.