Partially update WPF animation in storyboards / ParallelTimelines without new Begin ()?

I am working on a WPF application that displays a series of graphics elements (RectangleGeometries and Splines) that animate in sync with the video being displayed in the MediaElement.

The sync tree is structured as follows:

  • Storyboard (for controls: Begin (), Pause (), Seek () ...)
    • MediaTimeline (connected to MediaElement using Storyboard.SetTargetName ())
    • ParallelTimeline 0 (subdivided into ParallelTimelines for easier object management)
      • KeyframeAnimation 0 (animates some graphic element)
      • KeyframeAnimation 1 (animating another graphic)
      • ...
    • ... (maybe more ParallelTimelines ...)

Due to the dynamic nature of the displayed and animated elements, this is all created and managed in code, i.e. no XAML. Setting it up and playing, searching, etc. Works great.

The problem I am facing is as follows.

Animated elements can be updated (e.g. KeyFrames animations are updated, added, removed, ...) from time to time while the video is still displayed, although it may be paused. Simply updating the original animation has no effect as Freezable copies of all animations appear to be used while the Storyboard is playing (looking at the source code, this freezing seems to happen in the Begin () method when the clock is allocated and applied animation to Dependency Properties). I tried to make my animations unaffected (CanFreeze = false), but that just throws exceptions without playing anything.

Is there a way to update only some of the animations (e.g. only ParallelTimeline 0 and children) without causing the entire Storyboard to be reset and not interrupting sync with the original MediaTimeline, or forcing the MediaTimeline to reload (which involves reloading and re-searching the associated media and causing a significant delay) ?

+2


source to share





All Articles