May 21 2010

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:

<Window
	xmlns="http://schemas.microsoft.com/winfx/ 2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/ 2006/xaml"
	xmlns:i="http://schemas.microsoft.com/expression/ 2010/interactivity"
	xmlns:ei="http://schemas.microsoft.com/expression/ 2010/interactions"
	x:Class="WpfApplication1.MainWindow"
	x:Name="Window"
	Title="MainWindow"
	UseLayoutRounding="True"
	Width="640" Height="480">

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

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


May 17 2010

Silverlight 4 Tools for Visual Studio 2010 and WCF RIA Services 1.0 Released!

The final releases of the Silverlight 4 Tools for Visual Studio and WCF RIA Services are available for download here.

Read the original posts by Scott GuthrieTim Heuer, John Papa and don’t forget to take a look at these new themes.

Enjoy!


May 17 2010

Microsoft Silverlight 4 Data and Services Cookbook

The new book “Microsoft Silverlight 4 Data and Services Cookbook” by Gill Cleeren and Kevin Dockx is now available: 

This is the overview taken from the publisher site:

  • Design and develop rich data-driven business applications in Silverlight;
  • Rapidly interact with and handle multiple sources of data and services within Silverlight business applications;
  • Understand sophisticated data access techniques in your Silverlight business applications by binding data to Silverlight controls, validating data in Silverlight, getting data from services into Silverlight applications and much more!
  • Packed with practical, hands-on cookbook recipes, illustrating the techniques to solve particular data problems effectively within your Silverlight business applications.
  • I’ve just received my copy and I’m looking forward to read it in the next days!

    A sample chapter is available for download here.


    May 4 2010

    Slides and Code from my Silverlight 4 – MEF webcast

    Here you can find the sample code and slides (in italian) from my webcast around Silverlight 4 and MEF for the local XEdotNET user group.

    The samples contain the following topics:

    • Simple composition using the CompositionInitializer;
    • Multiple Exports;
    • Metadata;
    • Custom Attributes;
    • Dynamic object creation with ExportFactory;
    • Simple MVVM example using MEF;
    • MEF, MVVM and PRISM EventAggregator;
    • Dynamic XAP loading using DeploymentCatalog;
    • MEF, MVVM and Blend Sample Data.

    Click here to access the recording of the Live-meeting (italian language).

    Hope this helps and Happy Silverlighting!