locked
XAML Sequential animations. RRS feed

  • Question

  • Hi,
    i've written an application that downloads hand writing stroke data from a digital pen and then animates the hand writting in WPF. I've been using XAMLWriter.Save to dump out the XAML of the stroke geometry and the animations. The animations are made up of a large number of Point animations  that are called sequentially to animate the segment on the handwritting path. The sequential call is done using the Completed event of each animation and calling the appropiate animation to follow it. Obiovusly as this is in the "code behind" its not in the XAML.

    I was wondering if there was a way to specify animations/Storyboards occuring sequentially in the XAML i was hoping that I would be able to do it with a set of eventtriggers fired on completion of each animation. I know that I could artificially seet it up by setting the starttime of each animation appropriately but that doesn't seem like a very elegant approach. So really, my question is this..... Is there any way to to specify the sequential calling of a set of animations purely in the XAML without the need for some code behind it.

    Hopefully someone will have some good ideas on this

    Thanks in advance

    Roland
    Thursday, August 21, 2008 12:03 PM

Answers

  • -> Is there any way to to specify the sequential calling of a set of animations purely in the XAML without the need for some code behind it.

    From my limited knowledge in WPF, this seems cannot be done purely in XAML as you expect, is wiring up the things at codebehind not a good option for you?

    And I think you could also file a feature request at the connect site, since currently, WPF "only" supports specifying parallel animations rather than sequential animations in XAML:

    http://forums.expression.microsoft.com/en/blend/threads/


    Thanks
    • Marked as answer by Marco Zhou Friday, August 29, 2008 10:56 AM
    Wednesday, August 27, 2008 4:53 AM

All replies

  • mark, I wanta know it as well....
    珍惜生命,远离美女
    Thursday, August 21, 2008 12:39 PM
  • -> Is there any way to to specify the sequential calling of a set of animations purely in the XAML without the need for some code behind it.

    From my limited knowledge in WPF, this seems cannot be done purely in XAML as you expect, is wiring up the things at codebehind not a good option for you?

    And I think you could also file a feature request at the connect site, since currently, WPF "only" supports specifying parallel animations rather than sequential animations in XAML:

    http://forums.expression.microsoft.com/en/blend/threads/


    Thanks
    • Marked as answer by Marco Zhou Friday, August 29, 2008 10:56 AM
    Wednesday, August 27, 2008 4:53 AM
  •  
    Marco Zhou said:

    From my limited knowledge in WPF, this seems cannot be done purely in XAML as you expect, is wiring up the things at codebehind not a good option for you?

    I've implemented the sequential running of the animations with c# codebehind however ideally to be able to write it out to a single self contatained XAML file that would be able to both hold the point animation definitions and the deal with the sequencing of the individual animations so that the hand writting appears animated. So to do it with code behind I'd need to have the XAML and a dll that would read animations in and construct the event handlers that need to be associated with the preceeding animations Completed event.

    Marco Zhou said:

    And I think you could also file a feature request at the connect site, since currently, WPF "only" supports specifying parallel animations rather than sequential animations in XAML:


    I think that I'll submiot it as a potential improvement as it would be good to deal with both paralell and sequential animations.


    Thanks for getting back to me

    Roland



    • Edited by Roland Sutton Wednesday, August 27, 2008 3:25 PM Due to error
    Wednesday, August 27, 2008 3:24 PM
  • Hi Roland, given that you're generating the Point animations in code (if I understand correctly), you can control each keyframe's KeyTime (or begin time if you're not using keyframes). The sample here does that: http://blogs.msdn.com/expression/archive/2008/08/15/how-to-animate-a-drawing-line.aspx

    So long as all the animations are in the same Storyboard you only need to begin one Storyboard.

    -Steve (MS)
    Tuesday, September 2, 2008 6:53 PM
  • Steve White 000 said:

    Hi Roland, given that you're generating the Point animations in code (if I understand correctly), you can control each keyframe's KeyTime (or begin time if you're not using keyframes). The sample here does that: http://blogs.msdn.com/expression/archive/2008/08/15/how-to-animate-a-drawing-line.aspx

    So long as all the animations are in the same Storyboard you only need to begin one Storyboard.

    -Steve (MS)



     Hi Steve, thanks for the reply, I'd seen that example and looked at using the BeginTime property and increasing that by the duration of each subsequent path segment as I built up the animation, however the slight drawback there is that its not truly producing a sequential animation where the completion of one segment triggers the start of the next. This would mean that if the duration of an individual step was changed that the full animation sequence would not run correctly - So my understanding was that by setting the begin time, the animations are still running in paralell but that the actual "animated" bit can be set to occur at a predetermind delay after the start of the storyboard so giving the appearance of being sequential. However I think that I might go and revisit this and see how it looks, I figure that the in the short to medium term it would be aceptable to sacrifice the ability to edit the indiviual animation duration once the XAML has been produced.

    As an aside, do you have any idea as to whether there are any performance implications for setting lots of animations to run in this way?

    Roland
    Wednesday, September 3, 2008 9:28 AM