Silverlight 3: What’s New with 3D Support

This is the second post in a series where I will be walking through some of the new features in Silverlight 3. I enjoyed reading Tim Sneath’s blog post, but as I read the post I kept saying cool, but how do I do it. So in these posts I will try to answer the “how do I” questions around the new features.

Let’s get started.

Perspective 3D

Perspective 3d gives you the ability to “simulate” 3D using 2D objects.

Create a new Silverlight project

In order to create Silverlight 3 projects you will need to install Visual Studio 2008, and the Silverlight 3 SDK and tools. Create a Silverlight C# project called Perspective3D and accept the defaults which will create 2 projects in the solution.

In this example you will use an image to transform. Add an image to the ClientBin folder of the web project. I have added an image of my latest book.

Add an Image Element

Start with a basic image element.

<UserControl x:Class="Perspective3D.MainPage"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Image x:Name="SharePointBook"
               Width="100" Height="125">

When you run the project (F5) you will see the results below. I have cut out just the image to save space. Below is what the original image looks like before a perspective is added.


Rotate 70 degrees on the X axis

To rotate the image along the X axis you need to Projection and then add a PlaneProjection setting the RotationX attribute to the degree you want to rotate the image.

<Image x:Name="SharePointBook"
       Width="100" Height="125">
        <PlaneProjection RotationX="70"/>


You can set the X, Y and Z rotation. This table shows examples of the various perspectives.




X Axis




Y Axis




Z Axis





These attributes can be used together to create realistic 3D transforms of your elements.

Change the Rotation Center

You can also change the center of rotation by setting the CenterOfRotationX (Y or Z) attributes. This is set as a value between 0.0 and 1.0. By default the X and Y center is 0.5 and the Z center is 0.0. To rotate from the top of the image you set the CenterOfRotationX = 0.0


CenterOfRotationX 0.0 Top
CenterOfRotationX 1.0 Bottom

CenterOfRotationY 0.0 Left
CenterOfRotationY 1.0 Right


Comments (2)

  1. audio mastering says:

    Thanks for the interesting post! I think I will use the Z axis rotation.

  2. i am crossing my fingers for Silverlight 3.. thats really really cool…