Live Chat Icon For mobile
Live Chat Icon

How do I apply Transform when an event is occurred ?

Platform: WPF| Category: 2D Graphics

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.