ModernWPF.Animation.FadeOut C# (CSharp) Method

FadeOut() public static method

Animates the element's opacity to 1.
public static FadeOut ( UIElement element, System.TimeSpan duration, System.Action completedCallback = null ) : void
element UIElement The element.
duration System.TimeSpan The duration.
completedCallback System.Action The completed callback.
return void
        public static void FadeOut(UIElement element, TimeSpan duration, Action completedCallback = null)
        {
            if (element != null)
            {
                var da = new DoubleAnimation
                {
                    To = 0,
                    Duration = duration
                };
                if (completedCallback != null)
                {
                    da.Completed += (s, e) =>
                    {
                        completedCallback();
                    };
                }
                element.BeginAnimation(UIElement.OpacityProperty, da, HandoffBehavior.SnapshotAndReplace);
            }
        }