JoeMjr2
JoeMjr2

Reputation: 3944

WPF Animation set back to original size and location, but invisible

I am animating a control's size and position using DoubleAnimations. Here's what I want to achieve:

I want the control to animate to the new position and size. The final state that I want is for the controls to go back to their original position, but I want them to be invisible at that point. (This is because the application will be making changes to the appearance of the controls before making them visible again. They will reappear later looking different, and then animated again.)

If I set FillBehavior to FillBehavior.Stop, they do indeed go back to their original location and size, but they are immediately visible again at their original locations. I tried doing the following:

        ObjectToMove.BeginAnimation(HeightProperty, heightAnim);
        ObjectToMove.BeginAnimation(WidthProperty, widthAnim);
        trans.BeginAnimation(TranslateTransform.YProperty, anim1);
        trans.BeginAnimation(TranslateTransform.XProperty, anim2);
        ObjectToMove.Visibility = Visibility.Hidden;

However, this prevents the animation from being visible. I believe this is because the control is being made invisible before the animation completes.

What can I do?

Upvotes: 0

Views: 190

Answers (1)

Tony Vitabile
Tony Vitabile

Reputation: 8594

You probably need another animation that changes the Visibility to Hidden or Collapsed that you start after the control goes back to its original location and size, then another that changes the Visibility back to Visible that you start when you're done modifying the control's appearance.

Upvotes: 1

Related Questions