in src/Microsoft.Xaml.Behaviors/Layout/FluidMoveBehavior.cs [614:678]
private Storyboard CreateTransitionStoryboard(FrameworkElement child, bool usingBeforeLoaded, ref Rect layoutRect, ref Rect currentRect)
{
Duration duration = this.Duration;
Storyboard transitionStoryboard = new Storyboard();
transitionStoryboard.Duration = duration;
double xScaleFrom = (!usingBeforeLoaded || layoutRect.Width == 0.0) ? 1.0 : (currentRect.Width / layoutRect.Width);
double yScaleFrom = (!usingBeforeLoaded || layoutRect.Height == 0.0) ? 1.0 : (currentRect.Height / layoutRect.Height);
double xFrom = currentRect.Left - layoutRect.Left;
double yFrom = currentRect.Top - layoutRect.Top;
TransformGroup transform = new TransformGroup();
transform.Children.Add(new ScaleTransform() { ScaleX = xScaleFrom, ScaleY = yScaleFrom });
transform.Children.Add(new TranslateTransform() { X = xFrom, Y = yFrom });
AddTransform(child, transform);
string prefix = "(FrameworkElement.RenderTransform).";
TransformGroup transformGroup = child.RenderTransform as TransformGroup;
if (transformGroup != null && GetHasTransformWrapper(child))
{
prefix += "(TransformGroup.Children)[" + (transformGroup.Children.Count - 1) + "].";
}
if (usingBeforeLoaded)
{
if (xScaleFrom != 1.0)
{
DoubleAnimation xScaleAnimation = new DoubleAnimation() { Duration = duration, From = xScaleFrom, To = 1.0 };
Storyboard.SetTarget(xScaleAnimation, child);
Storyboard.SetTargetProperty(xScaleAnimation, new PropertyPath(prefix + "(TransformGroup.Children)[0].(ScaleTransform.ScaleX)", new object[0]));
xScaleAnimation.EasingFunction = this.EaseX;
transitionStoryboard.Children.Add(xScaleAnimation);
}
if (yScaleFrom != 1.0)
{
DoubleAnimation yScaleAnimation = new DoubleAnimation() { Duration = duration, From = yScaleFrom, To = 1.0 };
Storyboard.SetTarget(yScaleAnimation, child);
Storyboard.SetTargetProperty(yScaleAnimation, new PropertyPath(prefix + "(TransformGroup.Children)[0].(ScaleTransform.ScaleY)", new object[0]));
yScaleAnimation.EasingFunction = this.EaseY;
transitionStoryboard.Children.Add(yScaleAnimation);
}
}
if (xFrom != 0.0)
{
DoubleAnimation xAnimation = new DoubleAnimation() { Duration = duration, From = xFrom, To = 0.0 };
Storyboard.SetTarget(xAnimation, child);
Storyboard.SetTargetProperty(xAnimation, new PropertyPath(prefix + "(TransformGroup.Children)[1].(TranslateTransform.X)", new object[0]));
xAnimation.EasingFunction = this.EaseX;
transitionStoryboard.Children.Add(xAnimation);
}
if (yFrom != 0.0)
{
DoubleAnimation yAnimation = new DoubleAnimation() { Duration = duration, From = yFrom, To = 0.0 };
Storyboard.SetTarget(yAnimation, child);
Storyboard.SetTargetProperty(yAnimation, new PropertyPath(prefix + "(TransformGroup.Children)[1].(TranslateTransform.Y)", new object[0]));
yAnimation.EasingFunction = this.EaseY;
transitionStoryboard.Children.Add(yAnimation);
}
return transitionStoryboard;
}