1
votes

What is my actual problem?

I want to stop Storyboard animation but keep current value of animated properties and unfreeze those properties.

What I have tried?

I tried storyboard.Pause() but this will keep the animated properties frozen. (changing values has no effect) I want to be able to release all properties from storyboard.

storyboard.Stop() doesn't work because it either sets value of animated properties to end or start of the animation depending on the FillBehavior. Although it will unfreeze the properties.

I tried clearing storyboard.Childern but it throws exception unless storyboard is fully stopped.

I tried to make new storyboard with duration 0 with same animations, this will stop previous animations and storyboard it self will finish in no time, but here are the problems

  • I should know what animations were added in last storyboard (I already solved this by storing dependency objects with property path in a List)

  • I have to retrieve current value of animated properties from property path.

I am stuck at the last one because this does not exist in UWP

string propertyPath = "(UIElement.Projection).(PlaneProjection.RotationY)";

// all animated properties are double
double value = (double)dependencyObject.GetValue(???);

GetValue requires DependencyProperty but i have a string.


Note: I just want a solution to my actual problem (top of this post).

1
What kind of effect do you actually want to have? Stop the current animation and change to another animation?Barry Wang
When user starts to drag element I want to stop the animation but keep RotationY so it will be changed by user with drag. @BarryWang-MSFTM.kazem Akhgary
the second storyboard i tried to make was just a hack to stop previous storyboard. second storyboard has duration of 0 and will stop soon and also stops previous storyboard so RotationY would become free to change.M.kazem Akhgary
@BarryWang-MSFT I found the solutionM.kazem Akhgary

1 Answers

0
votes

I was able to solve this problem using following timeline

new DoubleAnimation { By = 0, Duration = TimeSpan.Zero }

With this timeline i don't have to know value of the properties. new storyboard on same elements and same property path's with duration 0 with this timeline will stop previous storyboard and keep their values. the new storyboard will also stop in no time and unfreeze the animated properties.