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:

WP7BehaviorExpression

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:

<Grid x:Name="ContentPanel" Grid.Row="1">
  <Canvas>
      <Image Source="Images/Desert.jpg" x:Name="image1">
          <interactivity:Interaction.Behaviors>
               <WP7:MultiTouchManipulationBehavior IsInertiaEnabled="True" IsRotateEnabled="True" IsTranslateEnabled="True" IsScaleEnabled="True" MinimumScaleRadius="1" MaximumScaleRadius="720"/>
          </interactivity:Interaction.Behaviors>
      </Image>

      <Image Source="Images/Jellyfish.jpg" x:Name="image2">
          <interactivity:Interaction.Behaviors>
             <WP7:MultiTouchManipulationBehavior IsInertiaEnabled="True" IsRotateEnabled="True" IsTranslateEnabled="True" IsScaleEnabled="True" MinimumScaleRadius="60" MaximumScaleRadius="360"/>
          </interactivity:Interaction.Behaviors>
      </Image>
  </Canvas>
</Grid>

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

 

Considerations

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.

Limitations

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!

2 thoughts on “Windows Phone 7, Multi-Touch Behaviors and the Surface samples for Silverlight

  1. Pingback: Tweets that mention Windows Phone 7, Multi-Touch Behaviors and the Surface samples for Silverlight | DavideZordan.net -- Topsy.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>