The Silverlight API provides some support for manipulation of 3D data, however it does not currently offer a full-blown 3D framework (as WPF does). Rather, Silverlight opts for a more light weight "3D perspective framework".
Specifically, rather than working with Viewport3D elements, and the assorted camera and lightening objects, any Silverlight which derives from the UIElement base class can change it?s X, Y and Z positioning via the Projection property. This property may be set to a PlaneProjection object, which is a very lightweight version of Viewport3D. In its simplest form, the PlaneProjection object can be configured with RotationX, RotationY and RotationZ properties. It is also possible to control the center point of the rotation (via CenterOfRotationX, CenterOfRotationY and CenterOfRotationZ properties) as well as global and local offsets.
As you would hope, the Blend IDE provides an editor in the Properties panel which will fully configure a PlaneProjection object and connect it to a UIElement. Assume you have configured an Image control, and wish to map the data into a 3D plane.
If you select the Image control on the artboard, you will see that the Transform section of the Properties panel supports a Projection sub-section. This area can be used to set the Projection property of any selected item on the artboard.
Like other range-centric controls of the Properties panel, you can use your mouse to adjust the values for the X, Y and Z projection settings (just click and hold on a range control and move your mouse). Again, rather than seeing a Viewport3D, you will see XAML such as the following:
Code Snippet
- <Image x:Name="imgCoCoLoCo" Margin="162,18,162,185"
- Source="/CoCoLoCo.png" Stretch="Fill">
- ????<Image.Projection>
- ????????<PlaneProjection RotationX="46"
- ??????????????? RotationY="12" RotationZ="-29"/>
- ????</Image.Projection>
- </Image>
Of course, you can also drive the project via code. Assume you had three Slider controls which allow you to change the X, Y and Z rotations. Also assume each ValueChanged event handler captures the new thumb location, and stores the value in some fitting fields. Each hander could call a helper function such as the following:
Code Snippet
- private void ChangeCamera()
- {
- ????PlaneProjection pp = new PlaneProjection();
- ????pp.RotationX = xVal;
- ????pp.RotationY = yVal;
- ????pp.RotationZ = zVal;
- ????????????
- ????if(imgCoCoLoCo != null)
- ????????this.imgCoCoLoCo.Projection = pp;????????????
- }
When you run the project, you can then view the results of mapping this 2D image onto a 3D plane. Simple, yes?
