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:

<Canvas>
    <Image x:Name="_image"
        Source="{Binding SelectedPicture}">
        <interactivity:Interaction.Behaviors>
            <behaviors:MultiTouchBehavior
                    IsInertiaEnabled="True"
                    IsTranslateXEnabled="True"
                    IsTranslateYEnabled="True"
                    IsRotateEnabled="True"
                    IsScaleEnabled="True"
                    MinimumScale="30" MaximumScale="200"
                    AreFingersVisible="False"/>
        </interactivity:Interaction.Behaviors>
    </Image>
</Canvas>

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

Happy Silverlighting!

Silverlight 5 Announced!

Today ScottGu announced some new amazing features that will be available in Silverlight 5. The complete list is available here:

http://www.microsoft.com/silverlight/future/

Planned release date: 1H 2011 (Silverlight 5 Beta)2H 2011 (Final Release)

Useful links:

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">
    <interactivity:Interaction.Behaviors>
        <Silverlight4:MultiTouchBehavior 
            IsInertiaEnabled="True"
            IsTranslateXEnabled="True" 
            IsTranslateYEnabled="True"
            IsRotateEnabled="True" 
            IsScaleEnabled="True"
            MinimumScale="10" MaximumScale="100"
            AreFingersVisible="True"/>
    </interactivity:Interaction.Behaviors>
</Image>

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 = 
        System.Windows.Interactivity
        .Interaction.GetBehaviors(image1);
    behaviors.Clear();
    var mtb = new MultiTouchBehavior
    {
        IsRotateEnabled = true,
        IsScaleEnabled = true,
        IsTranslateXEnabled = true,
        IsInertiaEnabled = true,
        AreFingersVisible = true,
        MinimumScale = 20,
        MaximumScale = 200
    };
    behaviors.Add(mtb);
    mtb.Move(new Point(200, 150), 45, 100);
}

private void btnDetach_Click(object sender, RoutedEventArgs e)
{
    var behaviors = 
        System.Windows.Interactivity
        .Interaction.GetBehaviors(image1);
    if (behaviors.Count > 0)
    {
        behaviors.Clear();
    }
}

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!

Duplex sample updated to Silverlight 4

I was following this thread on the Silverlight forums and was asked to update the Duplex sample to Silverlight 4.

Click here to download the code.

More information about Duplex Services are available here:

Happy Silverlighting!

Register for the Silverlight Firestarter!

Light up your Silverlight skills with the all-new Global Silverlight Firestarter!

What is the Silverlight Firestarter?

–          An Event: A one day, global, live streamed and on demand event keynoted by Scott Guthrie

–          Training: New self-paced labs and walk through videos

–          Interactive: Got questions? Get your answers! Watch live and ask the Silverlight product team questions during the event.

–          Why Silverlight? Silverlight is Microsoft’s strategic development platform for building interactive applications across desktop, phone, and the browser.

Something for Everyone

–          Just starting out with Silverlight? Watch our On-Ramp sessions and work on hands on labs to get you started.

–          Already Building business applications? Watch the event live and learn how to create compelling business applications with Silverlight.

–          Got questions? Engage with the Silverlight product team live or in person with our interactive chat.

When Register How Much?
December 2, 2010 8am to 5pm PT Register Online, Now! Nothing! This is a free event

After the live event keep fueling the fire!

Dive deeper with additional hands on labs and videos that build on the live session content, accelerating you ahead of the crowd.

–          Watch the entire event on demand!

–          Plus, new self-paced labs and walk through videos

–          On Ramp Labs (100 level)

  • Hands on labs specifically focused on helping new developers get up to speed quickly on Silverlight
  • Do you know WinForms? HTML? ASP.NET? Want to learn Silverlight? We have a lab for you!

–          Building Better Business Apps (200-300 level)

  • Hands on labs focused on taking advantage of Silverlight to build real world business applications
  • Apply Data Strategies, Patterns, Out of Browser, RIA Services, and much more using Silverlight

–          Turnabout is fair play! Watch a video of our experts doing the labs themselves.

F I R E S T A R T E R     L I V E     A G E N D A
8:00 am Silverlight Firestarter Keynote Scott Guthrie
9:00 am Masterful Data Strategies with Silverlight and WP7 Jesse Liberty
10:00 am 15 minute break
10:15 am Roll Out Your Business Apps Today with RIA Services Pete Brown
11:15 am MVVM: Why and How? Tips and Patterns using MVVM and Service Patterns John Papa
12:15 pm Lunch break
1:00 pm Silverlight Today and Tomorrow (Special Guest Panel) Panel
1:30 pm Building Real World Silverlight Apps Tim Heuer
2:30 pm 15 minute break
2:45 pm Tune Your Application: Profiling and Performance Tips Mike Cook & Jossef Goldberg
3:45 pm Killer Performance Tips for Silverlight Windows Phone 7 Jaime Rodriguez
5:00 pm After Party!

*** Sessions are subject to change

Spread the Word!

–          Blog and tweet to spread the word about the Firestarter!

–          Ask people to add the Twitter hash tag #slfs10 to their tweets

–          Use the banners and blog bling (attached)

Questions

Got questions? Ask slfs@microsoft.com

MEF Contrib is live!

Check out this great resource for MEF (Managed Extensibility Framework developers:

From the main site:

MefContrib is a community-developed set of extensions, tools and samples for the Managed Extensibility Framework (MEF).

The project is an open source project, licensed under the MS-PL license. MefContrib is about YOU. With your help we can make it a vibrant resource for MEF developers world-wide.

MEF Contrib is the one stop shop for all your MEF needs. Within you’ll find:

  • Community extensions to MEF like support for convention based registration, open generics and AOP.
  • Tools like Visual MEFX, a tool for diagnosing composition
  • Guidance, Quickstarts and Samples to help you learn the ropes from experts

Windows Phone 7 Developer Tools and Silverlight for Windows Phone 7 Toolkit released

Some useful links:

Downloads:

Blog posts:

Happy Silverlighting with Windows Phone!