It is very easy to create a rotating Image by using the storyboard- In this
article I'm going to create an Image which Rotates in any direction with the
help of storyboard and changing its size by the use of triggers in Expression
Blend 4.
<Window.Resources>
<Storyboard
x:Key="OnLoaded1">
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
Storyboard.TargetName="Image1">
<EasingDoubleKeyFrame
KeyTime="0:0:0.4"
Value="15.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3"
Value="-311.334"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3.5"
Value="-291.334"/>
<EasingDoubleKeyFrame
KeyTime="0:0:4"
Value="-291.334"/>
<EasingDoubleKeyFrame
KeyTime="0:0:6.5"
Value="277.999"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7"
Value="257.332"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7.5"
Value="257.332"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10"
Value="-32.668"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10.5"
Value="-34.668"/>
<EasingDoubleKeyFrame
KeyTime="0:0:11"
Value="-34.668"/>
<EasingDoubleKeyFrame
KeyTime="0:0:13.5"
Value="-19.335"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"
Storyboard.TargetName="Image1">
<EasingDoubleKeyFrame
KeyTime="0:0:0.4"
Value="131.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3"
Value="294"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3.5"
Value="291.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:4"
Value="291.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:6.5"
Value="315.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7"
Value="317.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7.5"
Value="317.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10"
Value="552.666"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10.5"
Value="527.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:11"
Value="527.333"/>
<EasingDoubleKeyFrame
KeyTime="0:0:13.5"
Value="291.333"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
Storyboard.TargetName="Image1">
<EasingDoubleKeyFrame
KeyTime="0:0:0.4"
Value="0"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3"
Value="1052.882"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3.5"
Value="1052.882"/>
<EasingDoubleKeyFrame
KeyTime="0:0:4"
Value="1052.882"/>
<EasingDoubleKeyFrame
KeyTime="0:0:6.5"
Value="2915.115"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7"
Value="2915.115"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7.5"
Value="2915.115"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10"
Value="4298.665"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10.5"
Value="4298.665"/>
<EasingDoubleKeyFrame
KeyTime="0:0:11"
Value="4298.665"/>
<EasingDoubleKeyFrame
KeyTime="0:0:13.5"
Value="5744.264"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
Storyboard.TargetName="Image1">
<EasingDoubleKeyFrame
KeyTime="0:0:3"
Value="1"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3.5"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:4"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:6.5"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7.5"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10.5"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:11"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:13.5"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:14"
Value="4.585"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
Storyboard.TargetName="Image1">
<EasingDoubleKeyFrame
KeyTime="0:0:3"
Value="1"/>
<EasingDoubleKeyFrame
KeyTime="0:0:3.5"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:4"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:6.5"
Value="1.762"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:7.5"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10"
Value="2.454"/>
<EasingDoubleKeyFrame
KeyTime="0:0:10.5"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:11"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:13.5"
Value="3.23"/>
<EasingDoubleKeyFrame
KeyTime="0:0:14"
Value="4.585"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard
x:Name="OnLoaded1_BeginStoryboard" Storyboard="{StaticResource
OnLoaded1}"/>
</EventTrigger>
At last we add 2 more Event triggers one for MouseDown( when we click on
image it will enlarge in size) and the other one is MouseUp( to set our image to
the previous position):
Here is a sample application for 3 different images with changing layout
background, MouseDown and MouseUp Events:
I am attaching the zip file for this application hoping that it is useful
for you.