Removing animation clock from certain dependency properties
Hi guys,
Is there a way to remove an animation clock from certain dependency properties? I have a transition animation which is affecting the visibility of certain elements whilst it transitions on. After it transitions on, I want to affect the value of the visibility property in code, but the base value is being overridden by the storyboard, even though it has completed. If I remove the animation clock, it changes all properties back to their base value. I want to keep some properties from the storyboard, but selectively remove the clocks from the dependency properties at will.
To clarify, I want the following behaviour:
* Storyboard A modifies the value of the visibility dependency property on objects B and C.
* When the Completed delegate for Storyboard A is triggered in C++, I'd like to override the visibility value on object C.
* The visibility dependency property for object B should remain as it was when it was animated.
Is there any easy way to achieve this? To be more specific, currently I have this:
* UserControl
** Grid
*** Some Element
** Stack
*** Child 1
*** Child 2
*** Child 3
*** ...
*** Child N
The transition storyboard modifies the visibility of each child independently so they appear staggered. After they appear, I want to toggle the visibility of the children at runtime. I can't remove the entire storyboard because the storyboard also effects properties on other elements (e.g. "Some Element" in the above example). I'd rather not split it into multiple storyboards as it gets difficult for our artist to see how it all looks when the two storyboards combine.
In theory, I could wrap all the children in a stack in a ContentControl, and I could use the storyboard to animate the visibility of the parent wrapper object, and then change the visibility of the child control in code, which is illustrated as follows:
** Stack
*** Child 1 Wrapper <-- visibility modified in storyboard
**** Child 1 <-- visibility modified in code
*** Child 2 Wrapper
**** Child 2
*** ...
*** Child N Wrapper
**** Child N
... However, this feels messy and adds a bunch more indirection into the hierarchy. Do you have any suggestions on how to best achieve my desired effects? Cheers,
-Steven
Is there a way to remove an animation clock from certain dependency properties? I have a transition animation which is affecting the visibility of certain elements whilst it transitions on. After it transitions on, I want to affect the value of the visibility property in code, but the base value is being overridden by the storyboard, even though it has completed. If I remove the animation clock, it changes all properties back to their base value. I want to keep some properties from the storyboard, but selectively remove the clocks from the dependency properties at will.
To clarify, I want the following behaviour:
* Storyboard A modifies the value of the visibility dependency property on objects B and C.
* When the Completed delegate for Storyboard A is triggered in C++, I'd like to override the visibility value on object C.
* The visibility dependency property for object B should remain as it was when it was animated.
Is there any easy way to achieve this? To be more specific, currently I have this:
* UserControl
** Grid
*** Some Element
** Stack
*** Child 1
*** Child 2
*** Child 3
*** ...
*** Child N
The transition storyboard modifies the visibility of each child independently so they appear staggered. After they appear, I want to toggle the visibility of the children at runtime. I can't remove the entire storyboard because the storyboard also effects properties on other elements (e.g. "Some Element" in the above example). I'd rather not split it into multiple storyboards as it gets difficult for our artist to see how it all looks when the two storyboards combine.
In theory, I could wrap all the children in a stack in a ContentControl, and I could use the storyboard to animate the visibility of the parent wrapper object, and then change the visibility of the child control in code, which is illustrated as follows:
** Stack
*** Child 1 Wrapper <-- visibility modified in storyboard
**** Child 1 <-- visibility modified in code
*** Child 2 Wrapper
**** Child 2
*** ...
*** Child N Wrapper
**** Child N
... However, this feels messy and adds a bunch more indirection into the hierarchy. Do you have any suggestions on how to best achieve my desired effects? Cheers,
-Steven
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Removing animation clock from certain dependency properties
To remove an animation value in code you can call ClearAnimation(dp), and to keep the animated value you just set it locally before removing the animation:
Is this what you want to do?
Code: Select all
element->SetVisibility(element->GetVisibility());
element->ClearAnimation<Visibility>(UIElement::VisibilityProperty);
Re: Removing animation clock from certain dependency properties
Apologies for the delay, I've had a long Christmas break. This sounds like a good solution and will most likely sort out my issue. I'll add this in and let you know if there are still any issues. Much appreciated, cheers.
-Steven
-Steven
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Removing animation clock from certain dependency properties
Setting this as solved then, thanks for the update.
Who is online
Users browsing this forum: No registered users and 2 guests