Use this approach when you need to completely bypass the WPF animation system. One scenario for this approach is physics animations, where at each animation step a new direction or position of animated objects needs to be recomputed based on the last set of object interactions.
Implementation Instructions
Unlike the other approaches described in this overview, to use per-frame callback you don't need to create a custom animation or key frame class.
Instead, you register for the Rendering event of the object that contains the objects you want to animate. This event handler method gets called once per frame. Each time that WPF marshals the persisted rendering data in the visual tree across to the composition tree, your event handler method is called.
In your event handler, perform your whatever calculations necessary for your animation effect and set the properties of the objects you want to animate with these values.
To obtain the presentation time of the current frame, the EventArgs associated with this event can be cast as RenderingEventArgs, which provide a RenderingTime property that you can use to obtain the current frame's rendering time.
For more information, see the Rendering page. For an example, see the Per-Frame Animation Sample.