How to stop an animation in C# / WPF?

前端 未结 8 824
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 08:54

I have something like this:

barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation(
    barProgress.Value, dNextProgressValue,
    new Duration(T         


        
8条回答
  •  悲哀的现实
    2020-11-28 09:30

    In my case I had to use two commands, my xaml has a button which fires a trigger, and its trigger fires the storyboard animation.

    I've put a button to stop animation with this code behind:

    MyBeginStoryboard.Storyboard.Begin(this, true);
    MyBeginStoryboard.Storyboard.Stop(this);
    

    I don't like it but it really works here. Give it a try!

提交回复
热议问题