I have a a bunch of WPF UserControls that internally trigger some animations upon user interactions. All animations have repeatbehavior = "true" and all animations have the same duration. Now I would like synchronize all those animations on one timeline so they are fading in and out in sync. No matter when the user triggerd the animations. For example if the animations all last 3 secs and the user triggers the 2nd animation 1.5 secs after the first, I still want the animations reach their maximum at the same time. Maybe I can define a global time line in a global resource dictionary that all animations that are defined somewhere in the UserControls can use? Preferably XAML only.
A:
Simply add all of your animations to a single TimelineCollection. Then add that TimelineCollection to your Storyboard.Children. Then they will all fire simultaneously.
Charlie
2009-08-05 17:18:16
AS I said the animations are defined throughout my usercontrols. I don't think there is a way to add animations that are defined in different usercontrols to the same timeline. Or maybe there is?
bitbonk
2009-08-06 09:52:46
Can you elaborate on how I would use the CompositionTarget.Rendering event with my Animation definitions?
bitbonk
2009-08-21 09:05:52
You'll have to move animation to code. In Rendering event, check which animations should be running and manually update corresponding properties based on a single timer variable. It's not a lot of work, just a few lines of SomeElement.SomeProperty = baseValue + rate * timePassed;
ima
2009-08-25 13:37:15