Fade UIElement - CSharp Windows.UI.Xaml.Media.Animation

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

Description

Fade UIElement

Demo Code


using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Media;
using System.Windows;
using System;/*from  w  ww .  j a v  a2s  .c  om*/
using PicView.Properties;

public class Main{
        internal static void Fade(UIElement element, Duration duration, TimeSpan begintime, double from, double to)
        {
            var da = new DoubleAnimation()
            {
                From = from,
                To = to,
                BeginTime = begintime,
                Duration = duration
            };
            element.BeginAnimation(UIElement.OpacityProperty, da);
        }

        internal static void Fade(UIElement element, double to, Duration duration)
        {
            var da = new DoubleAnimation()
            {
                To = to,
                Duration = duration
            };
            element.BeginAnimation(UIElement.OpacityProperty, da);
        }
}

Related Tutorials