Surface event handler being a b*tch

26 04 2011

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 Blinkar

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.

microsoft_surface2

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: