MultiTouch Behaviors available on NuGet

I’ve received several requests for publishing the MultiTouch Behaviors on the NuGet gallery so I created a simple package containing support for the Windows Phone and Silverlight platforms.

To enable your project for MultiTouch, just run the following command in the Package Manager Console and all the libraries and dependencies will be added to the Visual Studio project:

PM> Install-Package MultiTouchBehaviors

Alternatively just search for the package selecting Tools->Library Package Manager->Manage NuGet Packages for Solution from Visual Studio 2012.

If you are interested in creating a NuGet package for your open-source project, register an account here in the gallery and follow the instructions described in the section “Creating and Publishing a Package“: they are very clear and contain detailed information about the process.

The package definition for MultiTouch is also available in the Source Code section on CodePlex.

Happy Coding!

Multi-Touch Behaviors updated: Windows Phone “Mango” support, Manipulation / Inertia Processors and more

I’ve just published on CodePlex and the Expression gallery a new release of the Multi-Touch behaviors including these new features:

  • support for Windows Phone 7.1 Beta 2 (refresh) “Mango”;
  • added new property “IgnoredTypes” for excluding particular control types from the manipulations (thanks to Richie for the suggestions, feedback and code samples);
  • the “Manipulation Processor” and “Inertia Processor” are now exposed by the behavior in order to enable personalized manipulations and gestures;
  • new properties: CenterX, CenterY, Rotation, Scale permit to support custom gestures like “DoupleTap” zoom;
  • Silverlight 4 and Windows Phone 7.1 samples updated with a simple “DoubleTap” zoom example using the new exposed properties.

The source code and samples are available for download here.

Happy Silverlighting!

Using the Multi-Touch Behavior in a Windows Phone 7 Multi-Page application

In these days I’m receiving several questions in the Multi-Touch Behaviors forums about enabling Multi-Touch manipulations in Windows Phone applications composed by more than one page.

Today I’ve modified the available sample inserting an additional page containing an image enabled for translation, rotation, zoom and inertia via the usual “MultiTouchBehavior“:

Starting from release 0.6.1 it’s now possible to use the Behavior in different pages of the application, in this way enabling multi-touch in different elements of a Windows Phone 7 application.

As usually the sample code is available for download on, check out the Visual Studio solution “SilverlightWP7MultiTouch.sln” which contains all necessary libraries.

Happy Silverlighting!

Adding / Removing the Multi-Touch Blend Behavior using C# code-behind

I’ve received several requests about the modalities of enabling multi-touch on a UI element using the Behavior available on my CodePlex project.

The traditional syntax using XAML is here:

<Image Source="Images/Desert.jpg" x:Name="image1">
            MinimumScale="10" MaximumScale="100"

What about if you want to achieve the same result using C#? Just obtain a collection of behaviors for your element and then add/remove the MultiTouchBehavior using the following syntax:

private void btnAttach_Click(object sender, RoutedEventArgs e)
    var behaviors = 
    var mtb = new MultiTouchBehavior
        IsRotateEnabled = true,
        IsScaleEnabled = true,
        IsTranslateXEnabled = true,
        IsInertiaEnabled = true,
        AreFingersVisible = true,
        MinimumScale = 20,
        MaximumScale = 200
    mtb.Move(new Point(200, 150), 45, 100);

private void btnDetach_Click(object sender, RoutedEventArgs e)
    var behaviors = 
    if (behaviors.Count > 0)

As usually the source code is available for download on the Multi-Touch CodePlex project (check out the SilverlightWP7MultiTouch Solution).

Oh, did I already say that it also works on Windows Phone 7? 😉

Happy Silverlighting!

TechDays WPC 2010: I’ll be there! Speaking about Silverlight, Multi-Touch and Natural User Interfaces

This year I’ll be presenting about “Silverlight, Multi-Touch and Natural User Interfaces” at the Techdays WPC 2010 conference in Milan on November, 25 2010.

The same day I’ll be also at the MVP booth, if you’re attending the conference come and say Hi! 🙂

Happy Silverlighting!

Windows Phone 7, Multi-Touch Behaviors and the Surface samples for Silverlight

I’ve just finished some experiments using the Windows Phone 7 emulator and the “Microsoft Surface Manipulations and Inertia Sample for Microsoft Silverlightin order to enable Multi-Touch gestures using Blend Behaviors:


This new implementation, now available for download in the Expression Gallery, permits to enable Multi-Touch gestures (the usual translation, rotation, zoom and inertia) on separate User Controls available in the same container.

In this way you can apply distinct Multi-Touch manipulations (inertia included) to single elements using a single code in xaml:



Alternatively you can use Blend inserting a reference to the project MultiTouch.Behaviors.Silverlight.WP7 and then dragging the MultiTouchManipulationBehavior from the Assets section to the  control to be touch-enabled:

Multi-Touch Behavior Blend



This one has been an interesting exercise in porting code written for Silverlight to Windows Phone: I had only to create a Windows Phone 7 project and add to it the code already available for the Silverlight version and all worked well quite quickly.


At this time the behavior works only in the fixed Portrait orientation of Windows Phone: if you change to Landscape the manipulation doesn’t work well. I’ll have to investigate further and currently I don’t have a physical device to test (I’d really love to have a device to try it :)).

Happy Silverlighting!

Windows Phone 7 Multi-Touch Behavior videos #wp7dev

Some time ago I’ve started a Codeplex project dedicated to multi-touch, available on Codeplex at

The goal of this project is to provide an unified interface for Silverlight, WPF and Windows Phone 7 in order to provide multi-touch support using a visual approach via the concept of Behavior available in Expression Blend.

Recently I had the honor to welcome in the project a pillar of the Silverlight community, Laurent Bugnion, who is working on the Windows Phone 7 version of the Behavior:

Laurent has just published on his blog two awesome videos to get started with this new Behavior, and has created a specific section on his site to announce updates and publish content.

A special thanks to Pete Blois of the Expression Blend team for his help and contributions.

Stay tuned as we’ll be posting updates very soon 🙂

Happy Silverlighting!

Enabling Multi-touch gestures in WPF using Expression Blend 4 RC and the TranslateZoomRotate behavior

I’ve already blogged about adding multi-touch support to Silverlight applications using Blend behaviors (you can also read my italian language article).

This is a powerful and simple approach which is now available in WPF using Expression Blend 4 RC and the TranslateZoomRotateBehavior.

Let’s try to build a simple example:

1 – Open Expression Blend and create a new WPF project:

 2 – Drag a Rectangle in the MainWindows.xaml:

3 – Let’s add multi-touch gestures and inertia effects to the rectangle selecting the Assets->Behavior tab and dragging the TranslateZoomRotateBehavior inside the rectangle:

4 – Let’s examine the Properties:

It’s possible to set the supported gestures (All, None, TranslateX, TranslateY, Rotate, Scale), the constrainToParentBounds modality, the Minimum, Maximum Scale and the Rotational and Translate Friction associated to the inertia.

Let’s select the constrainToParentBounds check box and run the project using the Project->Run Project menu:

Cool, Multi-touch and inertia effects are now enabled for the rectangle without writing a line of code!

And this is the generated xaml:

	xmlns=" 2006/xaml/presentation"
	xmlns:x=" 2006/xaml"
	xmlns:i=" 2010/interactivity"
	xmlns:ei=" 2010/interactions"
	Width="640" Height="480">

	<Grid x:Name="LayoutRoot">
		<Rectangle Margin="149,106,133,191" Stroke="Black">
				<ei:TranslateZoomRotateBehavior ConstrainToParentBounds="True"/>
				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
					<GradientStop Color="Black" Offset="0"/>
					<GradientStop Color="#FF8F98CA" Offset="1"/>

The source code of the project is available for download here.

Experiments with Multi-touch: A Windows Phone Manipulation sample

I’ve just updated the project on CodePlex to Silverlight 4 RC and added a new sample of multi-touch using Windows Phone 7 manipulation capabilities starting from this how-to available in MSDN – “How to: Handle Manipulation Events” –

The modified sample uses an Image to illustrate the possibility to move and scale objects in the Windows Phone emulator using the “ManipulationDelta” event:

These are the steps to follow in order to enable Scale and Translation gestures in a Windows Phone application:

  • Just create a new “Windows Phone Application” from Visual Studio and then add an Image control in the MainPage.xaml using this code
<Canvas x:Name="ContentCanvas" Grid.Row="1">
    <Image Source="Images/Desert.jpg" Canvas.Left="99" Canvas.Top="100"
           x:Name="image1" Stretch="Fill" Width="300">
  • Then add an event handler for the “ManipulationDelta” event for applying a Scale and a Translate transform using the CompositeTransform available in Silverlight 4:
public MainPage()

    SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

    ManipulationDelta += image1_ManipulationDelta;
    _compositeTransform=new CompositeTransform();
    image1.RenderTransform = _compositeTransform;

private CompositeTransform _compositeTransform;

void image1_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    // Scale
    if (e.DeltaManipulation.Scale.X!=0)
       _compositeTransform.ScaleX *= e.DeltaManipulation.Scale.X;
    if (e.DeltaManipulation.Scale.Y!=0)
        _compositeTransform.ScaleY *= e.DeltaManipulation.Scale.Y;

    // Translation
    _compositeTransform.TranslateX += e.DeltaManipulation.Translation.X;
    _compositeTransform.TranslateY += e.DeltaManipulation.Translation.Y;

The source code is available for download from CodePlex:

Happy Silverlighting!

Multi-Touch enabling Silverlight Simon using Blend behaviors and the Surface sample for Silverlight

I have already blogged about using Blend behaviors to add Multi-Touch gestures and inertia effects to a generic Silverlight user control, so I wanted to use the same approach to add the same behaviors to the CodePlex project Simon.

I think that inserting multi-touch manipulation effects to a Silverlight application using Blend behaviors is an elegant way which makes the code very clear and readable.

To start you need to download the Multi-touch manipulation and inertia behavior (wow, more than 7000 downloads, great feedback! :)), which I already published on the Expression site.

This behavior is based on the code available in the Microsoft Surface Manipulations and Inertia Sample for Microsoft Silverlight, in my opinion the best example available for using multi-touch in Silverlight at this time.

The solution available contains a project named “MultiTouch.behaviors.Silverlight” which must be included in your application to enable the multi-touch functionalities.

To make the Silverlight/Blend Behavior work with Simon I’ve modified some code relative to the Zoom gesture in order to use a ScaleTransform (check out the source code on CodePlex:

To use the Behavior in XAML just add a reference to the “MultiTouch.Behaviors.Silverlight” project and use the following code:

<UserControl x:Class="SimonSilverlight.MainPage"
    xmlns:interactivity="clr-namespace:System.Windows.Interactivity; assembly=System.Windows.Interactivity"
    xmlns:multitouch="clr-namespace:MultiTouch.Behaviors.Silverlight; assembly=MultiTouch.Behaviors.Silverlight">
    <uc:Simon x:Name="Says">
            <multitouch:MultiTouchManipulationBehavior InertiaEnabled="True" TouchRotateEnabled="True"
                       TouchScaleEnabled="True" TouchTranslateEnabled="True"/>

Since we are using a Blend Behavior, we can also open the solution in Expression Blend, select the “MultiTouchManipulationBehavior” from the “Assets” section and drag it over the Simon control:

Happy Silverlighting!