How to stop WPF storyboard composed only in XAML?

Looks like I was running into two separate issues.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a animation defined in XAML (as a UserControl) that essentially switches between two images every second: Collapsed Visible It can be used in a window thusly: My problem is that when the window containing the animation closes, it keeps on running and causes a leak. I'm not able to stop the animation via RemoteAnimation_Unloaded() with storyboard.Stop()... it doesn't do jack. I've checked out both of those posts, but they don't apply: Post1 Post2 I am able to get into the unloaded method, but calling Stop() does not stop the animation.

From my understanding, it may be an issue with a call to Begin() for the storyboard. There is an overload with an isControlable parameter. However, since the animation is completely in XAML, I'm not sure how to affect this.

Wpf xaml animation storyboard wpf-usercontrols link|improve this question edited Mar 22 '11 at 13:37 asked Mar 22 '11 at 13:14Tim337115 93% accept rate.

Looks like I was running into two separate issues: First off, in . NET 3.5, storyboard animations can leak unmanaged memory (ugh): Link, Link Since I don't have the option to update my targets to . NET 4.0, I used the patch described in the links and it has stopped the leak.

Second, I was able to successfully hook up to my UserControl's Unloaded event, which is called when it's containing window is closed. I see others have had trouble with this event firing properly, but it seems to work for me. The only way to stop the animation (which was started via XAML with RepeatBehavior of "Forever") is: storyboard.

Begin(this, true); storyboard. Stop(this); This stops the animation and allows the GC to collect it.

Thanks, I was looking for a way to stop my "forever" animation but just calling Stop(this) didn't do it. Adding "true" to the Start(this) method did the trick. – Björn Nov 25 '11 at 8:14.

Please read these two posts: Unloaded event not triggered Disposing UserControls.

I've checked out both of those, but they don't apply. I am able to get into the unloaded method, but calling Stop() does not stop the animation. From my understanding, it may be an issue with a call to Begin() for the storyboard.

There is an overload with an isControlable parameter. However, since the animation is completely in XAML, I'm not sure how to affect this. – Tim Mar 22 '11 at 13:32 Why didn't you add that to the question?

Please do so now. – Erno Mar 22 '11 at 13:34 Have you tried: storyboard. Stop(this)?

– Erno Mar 22 '11 at 13:39 No dice... The jerk just keeps running. Why can't it be nice and actually listen to its own Stop() method?! :) – Tim Mar 22 '11 at 13:46 BTW: how do you know it keeps on running and causes a memory leak?

– Erno Mar 22 '11 at 19:53.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions