How to rotate an image to a particular angle in Wi

2019-06-27 04:32发布

问题:

I am a beginner in Windows Phone 7 Development, i am building an app in which i want to rotate an image to a particular angle, for example I have an image of an arrow pointing straight upwards, I want it to be pointing at lets say 15 degrees,

How will i do it? like a user enters the angle and image gets rotated. are there some functions available to do it?

回答1:

use a RotateTransform

<Image ... x:Name"myImg">
  <Image.RenderTransform>
    <RotateTransform Angle="90" />
  </Image.RenderTransform>
</Image>

in code you can rotate then by calling:

((RotateTransform)myImg.RenderTransform).Angle = x;