Sergey Zwezdin


Microsoft Regional Director

Microsoft MVP

3D-capabilities in Silverlight 3

As is known, in WPF there are great possibilities to work with 3D. Silverlight concedes WPF because it is cross-platform technology. However, in Silverlight 3 a support of 3D has appeared. Let's consider this subject.

Actually, if to look more detailed at possibilities 3D in Siliverlight 3 it is possible to understand quickly that it not that support which is present in WPF. It is logical. Actually, possibilities 3D in Silverlight are reduced to creation of projections of the image under different corners on three axes. Certainly, it not what it would be desirable in an ideal. Nevertheless this functionality allows to present our application in a three-dimensional kind.

Property Projection which is accessible to all objects is responsible for creation of 3D-projections in Silverlight 3. Using this property it is possible to set parametres of display of a control. Let's create the panel in which we will put standard controls.

<StackPanel Name="InputPanel" Grid.Row="1">
    <TextBlock Text="Text:"/>
    <TextBox />
    <ComboBox />
    <Button Content="Go!"/>
</StackPanel>

Now we will create a 3D-projection of our panel. Let's turn the panel on an axis X.

<StackPanel Name="InputPanel" Grid.Row="1">
    <StackPanel.Projection>
        <PlaneProjection RotationX="20" />
    </StackPanel.Projection>
    <TextBlock Text="Text:"/>
    <TextBox />
    <ComboBox />
    <Button Content="Go!"/>
</StackPanel>

That is interesting, values of parametres of 3D-projections can be changed by means of bindings and animations.

Let's test it. Let's create three Slider controls. Let's bind each such control to the axis.

<StackPanel>
    <Slider Value="{Binding ElementName=InputPanel, Path=Projection.RotationX, Mode=TwoWay}" Minimum="0" Maximum="720" />
    <Slider Value="{Binding ElementName=InputPanel, Path=Projection.RotationY, Mode=TwoWay}" Minimum="0" Maximum="720" />
    <Slider Value="{Binding ElementName=InputPanel, Path=Projection.RotationZ, Mode=TwoWay}" Minimum="0" Maximum="720" />
</StackPanel>
    
<StackPanel Name="InputPanel" Grid.Row="1">
    <StackPanel.Projection>
        <PlaneProjection RotationX="20" />
    </StackPanel.Projection>
    <TextBlock Text="Text:"/>
    <TextBox />
    <ComboBox />
    <Button Content="Go!"/>
</StackPanel>

Now we can rotate the image in 3D-space in a real time! :))) Here is how the application looks.

Download an example of the given application you can using reference below.

Comments

No Comments