Changing BeginTime stops animation
Posted
by SaphuA
on Stack Overflow
See other posts from Stack Overflow
or by SaphuA
Published on 2010-06-16T10:09:46Z
Indexed on
2010/06/16
10:12 UTC
Read the original article
Hit count: 231
Hi,
I have a storyboard as a resource in a rectangle with a simple doubleAnimation.
<Storyboard x:Name="EffectStoryboard">
<DoubleAnimation From="0" To="500" Storyboard.TargetName="WaveEffect" Storyboard.TargetProperty="Val0" RepeatBehavior="Forever" Duration="01:00:00" />
</Storyboard>
I start the storyboard in the loaded event of the rectangle:
private void Rectangle_Loaded(object sender, RoutedEventArgs e)
{
Rectangle rectangle = sender as Rectangle;
if (rectangle != null)
{
Storyboard storyboard = rectangle.Resources["EffectStoryboard"] as Storyboard;
//DoubleAnimation doubleAnimation = storyboard.Children[0] as DoubleAnimation;
//if (doubleAnimation != null)
//{
// doubleAnimation.BeginTime = new TimeSpan(0, random.Next(0, 60), random.Next(0, 60));
//}
storyboard.Begin();
}
}
The problem is that when I uncomment the commented code, the animation won't start anymore. Even when I use non-random values in the timespan.
Why?
© Stack Overflow or respective owner