I have created a UWP app that I want to implement the following requirements:
1)First I need to move several animated images from various canvas locations to a specific location
2)Then at the same time scale those images from its current size to zero on both x axis and y axis by the time when it reaches it's final destination.
This is my code:
public static void SendimageHome(FrameworkElement image, double fromX, double fromY, double scale)
{
Storyboard storyboard = new Storyboard();
DoubleAnimation animateX = CreateDoubleAnimation(image, fromX * scale, 200 * scale, "(Canvas.Left)", 2);
DoubleAnimation animateY = CreateDoubleAnimation(image, fromY * scale, -1 * scale, "(Canvas.Top)", 2);
storyboard.Children.Add(animateX);
storyboard.Children.Add(animateY);
storyboard.Begin();
}
private static DoubleAnimation CreateDoubleAnimation(FrameworkElement frameworkElement, double fromX, double toX, string propertyToAnimate, Double interval)
{
DoubleAnimation animation = new DoubleAnimation();
Storyboard.SetTarget(animation, frameworkElement);
Storyboard.SetTargetProperty(animation, propertyToAnimate);
animation.From = fromX;
animation.To = toX;
animation.Duration = TimeSpan.FromSeconds(interval);
return animation;
}
Using the above code, I have successfully managed to animate the objects from their current locations to their final destinations but scaling is eluding me. I can't figure out how to scale those images using c# code in UWP.
Thanks for any help.