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

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

Description

Create Fade In Effects

Demo Code


using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml;
using Windows.UI;
using System;//from ww w . java  2  s  .  co m

public class Main{
        public static Storyboard CreateFadeInEffects(UIElement target, TimeSpan beginTime, Duration duration, double from = 0, double to = 1)
        {
            var t1 = new DoubleAnimation
            {
                BeginTime = beginTime,
                Duration = duration,
                To = to,
                From = from > 0 ? from : target.Opacity,
            };

            Storyboard.SetTarget(t1, target);
            Storyboard.SetTargetProperty(t1, "Opacity");
            var sb = new Storyboard();
            sb.Children.Add(t1);
            return sb;
        }
}

Related Tutorials