Hello, I would like to dynamically modify animation properties, like From, To or Duration. I managed to do this. However, the current solution restarts the animation from the beginning, which I do not like.
Storyboard story = RectanglesControl.FindResource("RectanglesAnimationStoryboard") as Storyboard;
TimeSpan time = story.GetCurrentTime();
story.Stop();
ThicknessAnimation anim = (ThicknessAnimation)story.Children[0];
Thickness zero = new Thickness(0, 0, 0, 0);
Thickness off = new Thickness(0, -x, 0, 0);
anim.From = zero;
anim.To = off;
anim.Duration = new Duration(TimeSpan.FromMilliseconds(mt));
story.Begin(this, true);
story.Seek(time);
XAML:
<Storyboard x:Key="RectanglesAnimationStoryboard">
<ThicknessAnimation Storyboard.TargetProperty="Margin"
Storyboard.TargetName="RectanglesControl" From="0,-40,0,0"
To="0,0,0,0" RepeatBehavior="Forever" Duration="0:0:1" />
</Storyboard>
My unsuccessful trials are in
italic.
How to resume a storyboard to a previous state after making the above modifications?