steveh
Topic Author
Posts: 25
Joined: 07 Oct 2019, 12:50

Removing animation clock from certain dependency properties

10 Dec 2019, 18:37

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
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Removing animation clock from certain dependency properties

11 Dec 2019, 19:15

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:
element->SetVisibility(element->GetVisibility());
element->ClearAnimation<Visibility>(UIElement::VisibilityProperty);
Is this what you want to do?
 
steveh
Topic Author
Posts: 25
Joined: 07 Oct 2019, 12:50

Re: Removing animation clock from certain dependency properties

05 Jan 2020, 17:29

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
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Removing animation clock from certain dependency properties

16 Jan 2020, 11:01

Setting this as solved then, thanks for the update.

Who is online

Users browsing this forum: Bing [Bot] and 2 guests