Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I worry about stopping/disposing WPF animations?

I have a UserControl that when loading it starts:

<Storyboard x:Key="StFlash" RepeatBehavior="Forever" AutoReverse="True" >
    <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="img" From=".3" To="1" Duration="0:0:0.6">
        <DoubleAnimation.EasingFunction>
            <CircleEase EasingMode="EaseOut"/>
        </DoubleAnimation.EasingFunction>
    </DoubleAnimation>
</Storyboard>

Basically it makes an image blink forever. When I remove that user control should I worry about stopping the animation?

like image 950
Tono Nam Avatar asked Apr 08 '14 15:04

Tono Nam


1 Answers

Yes, by possibility you must stop the Animation, because it will be played until the garbage collector does not destroy your UserControl, and it may take some time. For this purpose you may use the Unloaded event for UserControl.

For more information, see this link:

WPF Animations Tips and Tricks

like image 166
Anatoliy Nikolaev Avatar answered Oct 19 '22 17:10

Anatoliy Nikolaev