Reputation: 1001
I am using gif animation in WPF application, an external dll WpfAnimatedGif.dll is used for showing the animation. The animation is working properly, but I am unable to pause/stop it on a certain event let say button click, how can I do it, kindly guide me, my xaml code is given below
<Image x:Name="scaner" Stretch="UniformToFill" gif:ImageBehavior.AnimatedSource="{StaticResource gifImage}" >
Upvotes: 1
Views: 2599
Reputation: 11
You can try this, use reference
xamlAnimationWpf Nuget <br>
var controller = AnimationBehavior.GetAnimator(myGif); <br>
controller.Pause();<br>
For those who try another way
Upvotes: 1
Reputation: 77294
According to your documentation (which you should have read yourself) this will work:
private void Button_Click(object sender, RoutedEventArgs e)
{
var controller = ImageBehavior.GetAnimationController(this.scaner);
controller.Pause();
}
Please note that working directly with button functions is not the prefered way in WPF, if you want to use the full power I suggest using MVVM and the command pattern instead.
Upvotes: 2