Ton*_*Nam 5 wpf animation user-controls dispose storyboard
我有一个UserControl加载时开始:
<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>
Run Code Online (Sandbox Code Playgroud)
基本上它会使图像永远闪烁. When I remove that user control should I worry about stopping the animation?
是的,有可能你必须停止动画,因为它将被播放,直到垃圾收集器不会破坏你的UserControl,它可能需要一些时间.为此,您可以将Unloaded事件用于UserControl.
有关更多信息,请参阅此链接:
WPF Animations Tips and Tricks