So… pasting code is still tricky. But I think this will work. This code is what I used when I wanted to rotate an Image object declared in XAML. To be clear, this allows me to create a rotating image without any C# or VB code. Personally I chose to rotate this picture:
The CenterX and CenterY property of RotateTransform should be half of the Image objects width and height. This can be found by using databindings but that’s another post completely.
<Style x:Key="AnimationImage" TargetType="{x:Type Image}">
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="0" CenterX="20" CenterY="20" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="true">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle"
From="0" To="360" Duration="0:0:1.5" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>

[...] to WordPress 28 02 2010 Ok, so maybe I did a post like this before with a less than stellar result. At least it was better than my new solutions where I paste images and raw black text into the [...]
how to flip an image in wpf
Neat.
exactly what i was looking for. thanks
Thank you for this post. If you run this code above, it doesn’t look exactly like the gif animation above it. The visual trick in this image is that, the individual “ticks” (or “lines”) always occupy the same top-of-the-hour clock positions (12 o’clock, 1 o’clock, etc.) — and never appear in-between. When you run the code above, WPF renders frames at a high rate (60 fps by default) so the “ticks” smoothly move between clock positions, which undesirably changes the effect. To make it look exactly like the gif above, you need change the duration to 1s and make the frame rate 12 fps like this:
…
…
Sorry, the XAML didn’t show up…
<Storyboard Timeline.DesiredFrameRate="12"> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle" From="0" To="360" Duration="0:0:1" RepeatBehavior="Forever"/></Storyboard>
[...] solution is based on this post. Share this:EmailDiggFacebookTwitterLike this:LikeBe the first to like this. Posted by [...]