Tag Archives: Touch


Working with Touch (in .Net 4.0)

Extracted from: //random.tonywilliams.me.uk/post/745164436/working-with-touch-in-net-4-0

For the past several months I’ve been hammering away at the touch app for Graphic.ly and I’ve picked up a few hints and tricks along the way.

The first tip is to get a decent touch monitor or at least a touch machine that you can develop on. I’m using the Dell SX2210T monitor and couldn’t be happier; within seconds you’re ready to do some touch magic!

My second tip is to use the Surface Toolkit from Microsoft. This however will limit your app to Windows 7 only where as if you choose to go with other libraries for touch your apps may work in older versions but just not respond to touch.

If you plan to go with this library (and I recommend you do) there here are some helpful links:

As you can see from the Controls link there are a number of controls to play with; the two that are mainly used in the Graphic.ly app are the SurfaceWindow andSurfaceScrollViewer.

The SurfaceWindow provides UI responses to touch via the Touch Visualizations as well as display on a touch monitor in a multi-monitor setup.

The SurfaceScrollViewer simply adds alot of touch magic to the ScrollViewer; anywhere you could use a ScrollViewer then use the SurfaceScrollViewer. There is not much to do in terms of quickly getting touch on your app when you use the control from the toolkit library. In the Graphic.ly app the Store, Collection and Activity Stream are all examples of the SurfaceScrollViewer in action.

The problem I’m having with the SurfaceScrollViewer is having them nested; if you checkout the Store/Collection you’ll see I have rows of SurfaceScrollViewers. Swiping back and forth works fine but I just cannot get it to work up and down. Seems to be the child SurfaceScrollViewer handles all the touch events and won’t pass it along, does this mean nested SufaceScrollViewers will never work? Nope, this just means another touch challenge to conquer 😉

My 3rd and final tip (for the moment) is this


If you have hooked up some TouchEvents AND some ManipulationEvents then you’ll know that the ManipulationEvents prevents the TouchEvents from firing; in other words you can swipe but not press. In the “ManipulationCompleted” event I check to see if the change is small enough to consider it not a swipe; “e.Cancel()” will cancel this event and let the TouchEvents bubble through.