I have a situation where I need to determine if I’ve reached the end of a Storyboard, and then need to seek to the end of it.
I want to do:
storyboard.Seek(timespan);
However, if timespan is longer than the storyboard’s duration, I get an exception. If I look at
storyboard.Duration.TimeSpan
I get an error because the Duration is Automatic. This means I can’t do “if( timespan > storyboard.Duration.TimeSpan) …”
Once I know that the position I’m seeking is past the end of the storyboard, I need to just seek to the end of the storyboard. I could do this with storyboard.Seek(storyboard.Duration.TimeSpan), but again, I can’t use Duration because it is Automatic.
It seems like all my problems could be solved if I can force the Duration away from Automatic. Hopefully I’m just missing something simple.
Maybe I don’t understand something, but if you always need to seek to the end of the animation why don’t you use the seektofill method?
MSDN link
Also, here is the documentation on the Storyboard Duration structure, with an explanation on how you can set it to something other than automatic if you need to – but if you always need to go to the end I’d just use the skiptofill method:
MSDN link