RectNavigation.Animate.Opacity C# (CSharp) Method

Opacity() public static method

public static Opacity ( UIElement element, double from, double to, double seconds, AnimationCompletedDelegate callback ) : void
element System.Windows.UIElement
from double
to double
seconds double
callback AnimationCompletedDelegate
return void
        public static void Opacity(UIElement element, double from, double to, double seconds, AnimationCompletedDelegate callback)
        {
            DoubleAnimation fadeOutAnimation = new DoubleAnimation
            {
                From = from,
                To = to,
                Duration = new Duration(TimeSpan.FromSeconds(seconds)),
                FillBehavior = FillBehavior.Stop
            };
            element.Opacity = to;
            if (callback != null)
            {
                fadeOutAnimation.Completed += (sender, _) => callback(sender, _);
            }
            element.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
        }

Same methods

Animate::Opacity ( UIElement element, double from, double to, double seconds ) : void

Usage Example

 private void setRectVisible()
 {
     Animate.Opacity(ArrowLeftViewBox, ArrowLeftViewBox.Opacity, 1, 0.2);
     Animate.Opacity(ArrowRightViewBox, ArrowRightViewBox.Opacity, 1, 0.2);
     Animate.Opacity(TopTextViewBox, TopTextViewBox.Opacity, 1, 0.2);
     Animate.Opacity(BottomTextViewBox, BottomTextViewBox.Opacity, 1, 0.2);
     Animate.Opacity(Hand, Hand.Opacity, 1, 0.2);
     Animate.Opacity(InnerRect, InnerRect.Opacity, 1, 0.2);
     PointerArrow.Visibility = Visibility.Hidden;
 }