I don't know much about WPF, but in Silverlight or WP7, the children of Storyboardare of type TimeLine. Also, the StoryBoard itself will have an event Completedthat you would attach to. Thus, at least the first code fragment will look like this: -
private void storyboard_Completed(object sender, EventArgs e)
{
Storyboard sb = (Storyboard)sender;
DoubleAnimation completedAnimation = (DoubleAnimation)sb.Children[0];
Now for the difficult bit.
Storyboard.SetTarget Silverlight. , , , SetTarget. , , , Get, Set, Storyboard.SetTarget.
: -
public static class StoryboardServices
{
public static DependencyObject GetTarget(Timeline timeline)
{
if (timeline == null)
throw new ArgumentNullException("timeline");
return timeline.GetValue(TargetProperty) as DependencyObject;
}
public static void SetTarget(Timeline timeline, DependencyObject value)
{
if (timeline == null)
throw new ArgumentNullException("timeline");
timeline.SetValue(TargetProperty, value);
}
public static readonly DependencyProperty TargetProperty =
DependencyProperty.RegisterAttached(
"Target",
typeof(DependencyObject),
typeof(Timeline),
new PropertyMetadata(null, OnTargetPropertyChanged));
private static void OnTargetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Storyboard.SetTarget(d as Timeline, e.NewValue as DependencyObject);
}
}
SetTarget : -
StoryboardServices.SetTarget(completedAnimation, bomb);
: -
Bomb completedBomb = (Bomb)StoryboardServices.GetTarget(completedAnimation);