Friday, 15 August 2014

c# - Get element back in completed event after Storyboard.Begin(element) -



c# - Get element back in completed event after Storyboard.Begin(element) -

must simple, takes me dozens of minutes solve. that's why asking.

// start animation var storyboard = new storyboard(); ... storyboard.completed += storyboard_completed; storyboard.begin(control); // << "control" static void storyboard_completed(object sender, eventargs e) { var storyboard = sender storyboard; ... // how "control" here? }

i can utilize properties or perhaps create sort of tag storyboard (attached property?). can't complicated obvious task.

the completed event inherited timeline.completed event. can see uses standard eventargs object, clearly, there store reference command may used in animation.

the simplest way hold of reference command applied animation on, define private fellow member variable in class:

private uielement animatedcontol = null;

...

// start animation var storyboard = new storyboard(); ... storyboard.completed += storyboard_completed; storyboard.begin(control); animatedcontol = control;

...

static void storyboard_completed(object sender, eventargs e) { var storyboard = sender storyboard; ... // animatedcontol here }

c# wpf storyboard

No comments:

Post a Comment