tags:

views:

337

answers:

1

I am just starting out using WPF. I want to rotate an image when i click a button but I don't want the image to rotate in one instant rotation. I want the use to see the image rotate one degree at a time. What is the easiest way to do this in C#?

+4  A: 

Apply a RotateTransform to the Image, with its initial Angle set to 0. Then animate the transform's Angle property in the normal way.

If you specifically want a discrete rotation, where the rotation visibly clicks over in one-degree jumps, use a DoubleAnimationUsingKeyFrames instead of a normal DoubleAnimation, and make each key frame a DiscreteDoubleKeyFrame. (You'll probably want to generate the storyboard programmatically in this case because you'll have a lot of key frames.)

itowlson