Any type of transform can be applied when an event has occurred.
The following lines of code apply a ’RotateTransform’ when the mouse is moved over the image.
[XAML]
<Image Source='pda.ico' MouseEnter='Image_MouseEnter' MouseLeave='Image_MouseLeave'>
<Image.RenderTransform>
<RotateTransform Angle='0' x:Name='ImageRot'/>
</Image.RenderTransform>
</Image>
[C#]
private void Image_MouseEnter(object sender, MouseEventArgs e)
{
ImageRot.Angle = 30;
}
private void Image_MouseLeave(object sender, MouseEventArgs e)
{
ImageRot.Angle = 0;
}
Share with