Hello,
Welcome to our Microsoft Q&A platform!
In order to scale the images during the animation, first please change the frameworkElement’s parameter type as DependencyObject instead of FrameworkElement type in the CreateDoubleAnimation method. Then please use DoubleAnimation to animate a ScaleTransform which is assigned to the Image’s RenderTransform as following:
public static void SendimageHome(FrameworkElement image, double fromX, double fromY, double scale)
{
Storyboard storyboard = new Storyboard();
// image is the target element
image.RenderTransform = new ScaleTransform { ScaleX = 1, ScaleY = 1 };
DoubleAnimation animateScaleX = CreateDoubleAnimation(image.RenderTransform, 1, 0, "(ScaleTransform.ScaleX)", 2);
storyboard.Children.Add(animateScaleX);
DoubleAnimation animateScaleY = CreateDoubleAnimation(image.RenderTransform, 1, 0, "(ScaleTransform.ScaleY)", 2);
storyboard.Children.Add(animateScaleY);
storyboard.Begin();
}
private static DoubleAnimation CreateDoubleAnimation(DependencyObject 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;
}
Thanks