Reputation: 335
I am doing a small application which tries to do animation with an Image. I want the image to come into view like this . How do I go about doing it in WPF using C# Code? Thank You
Upvotes: 0
Views: 2715
Reputation: 35584
You can put the image into a Canvas
, and animate its position and size. Here is an example.
For choosing the moment to begin the animation in the C# code, you can use something like that:
(XAML)
<Canvas x:Name="container" ...>
<Canvas.Resources>
<Storyboard x:Key="MyAnimation">
<DoubleAnimationUsingKeyFrames ... />
...
</Storyboard>
</Canvas.Resources>
<Image x:Name="image" .../>
</Canvas>
(C#)
var a = container.FindResource("MyAnimation") as Timeline;
image.BeginAnimation(a);
Upvotes: 1