Create Scale Fade In Effects - CSharp Windows.UI.Xaml.Media.Animation

CSharp examples for Windows.UI.Xaml.Media.Animation:Animation

Description

Create Scale Fade In Effects

Demo Code


using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml;
using Windows.UI;
using System;//from w  w w. j  a  va2 s. c o  m

public class Main{
        public static Storyboard CreateScaleFadeInEffects(UIElement target, TimeSpan beginTime, TimeSpan duration, double opacityFrom = 0, double opacityTo = 1)
        {
            var scaleX = new DoubleAnimation
            {
                BeginTime = beginTime,
                Duration = duration,
                EasingFunction = new PowerEase(),
                To = 1,
            };

            Storyboard.SetTarget(scaleX, target);
            Storyboard.SetTargetProperty(scaleX, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");

            var scaleY = new DoubleAnimation
            {
                BeginTime = beginTime,
                Duration = duration,
                EasingFunction = new PowerEase(),
                To = 1,
            };

            Storyboard.SetTarget(scaleY, target);
            Storyboard.SetTargetProperty(scaleY, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");

            var opacityIn = new DoubleAnimation
            {
                BeginTime = beginTime,
                Duration = duration,
                From = opacityFrom,
                To = opacityTo,
            };

            Storyboard.SetTarget(opacityIn, target);
            Storyboard.SetTargetProperty(opacityIn, "Opacity");

            var sb = new Storyboard();
            sb.Children.Add(scaleX);
            sb.Children.Add(scaleY);
            sb.Children.Add(opacityIn);
            return sb;
        }
}

Related Tutorials