In this tutorial we will rotate an image left to right with a slider control.
Steps
1- Place an image on the stage
2- on the image add a PlaneProjection, this can easily be done by editing the Projection / Rotation / Y in the properties panel
3- name the PlaneProjection to x:Name=”rotater”
4- add a slider to the stage
5- name the slider x:Name=”rotateYSlider”
6- on the slider set ValueChanged=”changeRotateY”
View all parts of the tutorial
Part 1 – Scaling Objects with a Slider control in Silverlight
Part 2 – Using RotationX to rotate Objects in Silverlight
Part 3 – Using RotationY to rotate Objects in Silverlight
Use the Rotate Y slider to rotate the image
XAML code
<Image Margin="49,-14,54,96" RenderTransformOrigin="0.5,0.5" Source="hulu.jpg" Stretch="Fill" d:LayoutOverrides="Width">
<Image.Projection>
<PlaneProjection x:Name="rotater" RotationX="1" RotationY="1"/>
</Image.Projection>
</Image>
<Slider x:Name="rotateYSlider" Height="26" Margin="282,0,218,28" VerticalAlignment="Bottom" Maximum="180" ValueChanged="changeRotateY" Style="{StaticResource SliderStyle1}"/>
C# code
private void changeRotateY(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
{
rotater.RotationY = rotateYSlider.Value;
rotater.RotationY = rotateYSlider.Value;
}