Having a Silver Touch... As in the Wintellect Silverlight Touch Library, LightTouch

In looking though my past posts it doesn't look like I've done one specifically for "touch." That ends today... Okay, okay, it's Silverlight too, but it's the touch that, well, touched me.

If you need someone to blame for today's post (besides me of course Wink, Mike Taulty's recent post, LightTouch–Silverlight Touch Library from Wintellect, is what sparked my interest.

Hosted on Codeplex, the Wintellect Silverlight Touch Library (aka. LightTouch), provides multi-touch support for Silverlight apps (funny that).

The Wintellect Silverlight Touch Library is a reusable library that provides Multi-Touch support for Silverlight applications by via Manipulations, Gestures, and specialized Behaviors and controls.

The Wintellect Silverlight Touch Library has been developed to augment the limited out-of-the-box support available for Touch interactions in the current releases of Silverlight. These enhancements include:

  • Attaching Manipulation events to controls in XAML markup via attached Behaviors.
  • Higher-level Gesture support via attached behaviors. This has been implemented to provide parity with the Gesture implementation included in the Silverlight for Windows Phone Toolkit.
  • Attached Behaviors that allow controls that contain a ScrollViewer (such as the ListBox) to respond to touch-based scrolling. This includes the use of inertia in the scrolling.
  • A specialized ComboBox implementation that also incorporates the smooth scrolling, but does not close the popup as a result of the conclusion of the Touch operation.

The included sample app gives you an chance to play with this library;

image

The code behind this is very simple;

private void TouchShapeBehavior_ManipulationStarted(Object sender, Manipulation2DStartedEventArgs e)
{
var senderShape = (Shape)sender;
senderShape.Tag = senderShape.Fill;
senderShape.Fill = new SolidColorBrush(Colors.Yellow);
}

private void TouchShapeBehavior_ManipulationDelta(Object sender, Manipulation2DDeltaEventArgs e)
{
var senderShape = (Shape)sender;
var translateTransform = (TranslateTransform)senderShape.RenderTransform;
translateTransform.X += e.Delta.TranslationX;
translateTransform.Y += e.Delta.TranslationY;
}

private void TouchShapeBehavior_ManipulationCompleted(Object sender, Manipulation2DCompletedEventArgs e)
{
var senderShape = (Shape)sender;
//TODO: This should really be done at the end of inertia, otherwise it will take the original color and keep moving...
senderShape.Fill = senderShape.Tag as Brush;
}

And the XAML;

image

And as you'd expect the entire library's source is available and is under the MS-PL license.

image

So, why oh why am I blogging about this here? How is this "fun?"

Infrastructure/platform code we don't have to code is time we can be coding our apps. I have much more fun spending time on my actual app then I do writing base platform stuff (mostly). And it's fun to see the guts of something like this (well, I think it's fun at least...lol  Wink

If you're looking at include multi-touch in your Silverlight app, then this library might be one you want to check it.

 

Page image, touching the clouds, curtsey of Eddi van W

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.