Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Animation Troubles
3 replies. Latest Post by Bill Reiss on August 17, 2007.
(0)
damoxc
Member
90 points
46 Posts
08-17-2007 9:56 AM |
Does anyone have any ideas why the `Completed` event wouldn't be being fired when an animation has completed?
Also I can't seem to create an animation programmatically, have to define a Storyboard with 2 DoubleAnimations in the xaml to be able to use them. Silverlight throws an error when trying to use the Storyboard.Children.Add() method.
If anyone can shed any light on those 2 problems it would be greatly appreciated
Thanks, Damien
luisabreu
Participant
1676 points
612 Posts
08-17-2007 10:02 AM |
hello.
1. that sounds weird. i believe that there were some changes after the alpha refresh was released. however, i think that the problem you mentioned wasn't one of them (i recall having seen that the completed event would fire when you call begin [1]).
2. that's a known issue that has existed for a long time.
[1] http://www.andybeaulieu.com/Home/tabid/67/EntryID/78/Default.aspx
08-17-2007 10:30 AM |
1. Yeah it works ok as long as defining the eventhandler and the method being fired is all in the codebehind of the xaml, but I'm performing this in a seperate class this time and it seems to not like it.
Storyboard story = _rootCanvas.FindName("moveDragBack") as Storyboard;DoubleAnimation left = _rootCanvas.FindName("moveDragBackLeft") as DoubleAnimation;DoubleAnimation top = _rootCanvas.FindName("moveDragBackTop") as DoubleAnimation;left.SetValue(Storyboard.TargetNameProperty, _drag.Name);left.SetValue(Storyboard.TargetPropertyProperty, "(Canvas.Left)");left.From = (double)_drag.GetValue(Canvas.LeftProperty);left.To = _originalX;left.RepeatBehavior = new RepeatBehavior(1);top.SetValue(Storyboard.TargetNameProperty, _drag.Name);top.SetValue(Storyboard.TargetPropertyProperty, "(Canvas.Top)");top.From = (double)_drag.GetValue(Canvas.TopProperty);top.To = _originalY;top.RepeatBehavior = new RepeatBehavior(1);story.Completed += new EventHandler(story_Completed);story.Begin();
That's the code I'm using so I'm not sure why it won't fire it.
2. Ah ok, just use this work around until it's fixed then.
Cheers again.
Bill Reiss
Contributor
4840 points
919 Posts
08-17-2007 11:18 PM |
I've had issues with things like this if you try to do it before the Loaded event happens for the Canvas, if you do it in the Loaded event or after it's fine. Not sure if that's your problem though.