c# - Multiple animations in a Storyboard at the same time? -
i created few coloranimations , want them run @ same time (whether run syncronized doesn't matter). sadly 1 of them runs.
storyboard = new storyboard(); //animation auditorium coloranimation spotlightanimation = new coloranimation(); spotlightanimation.to = color.fromargb(1, convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255))); spotlightanimation.duration = timespan.fromseconds(3); spotlightanimation.completed += new eventhandler(storyboard_completed); this.registername("myspotlight", karte.spotlightauditorium); storyboard.settargetname(spotlightanimation, "myspotlight"); storyboard.settargetproperty(spotlightanimation, new propertypath(spotlight.colorproperty)); storyboard.children.add(spotlightanimation); //animation wohnzimmer coloranimation spotlightwohnzimmeranimation = new coloranimation(); spotlightwohnzimmeranimation.to = color.fromargb(1, convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255))); spotlightwohnzimmeranimation.duration = timespan.fromseconds(3); spotlightanimation.completed += new eventhandler(storyboard_completed); this.registername("myspotlightwonzimmer", karte.spotlightwohnzimmer); storyboard.settargetname(spotlightwohnzimmeranimation, "myspotlightwonzimmer"); storyboard.settargetproperty(spotlightwohnzimmeranimation, new propertypath(spotlight.colorproperty)); storyboard.children.add(spotlightwohnzimmeranimation); storyboard.begin(this); } void storyboard_completed(object sender, eventargs e) { (storyboard.children[0] coloranimation).to = color.fromargb(1, convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255)), convert.tobyte(random.next(0, 255))); storyboard.begin(this); }
new answer :
i think launched animation may interfering , may try :
- reuses same storyboard each time stop launched animation , clear children,
launch animation below snippet :
this.beginstoryboard(stboard, handoffbehavior.snapshotandreplace, true);
otherwise, each animation work separetly ?
also notice subscribe each animation completed instead of subscribing storyboard : why ?
old answer :
hello,
can provide whole code ? : spotlightwohnzimmeranimation class'name or instance ?
i follow launch animation code : http://blog.lexique-du-net.com/index.php?post/2009/07/07/create%2c-launch-and-control-a-wpf-animation-from-code
@brandon: think animating not declared in xaml spotlight... , creating animation allow more flexibility customizing parameters @ runtime , not design time...1.
Comments
Post a Comment