Search code examples
c#wpfbuttonanimated-gif

wpf loading a gif image animation


I wanted to do a simple button_click that would load an animated gif and have it loop 3 times.

The closest example which is not a Winform example, is Mediaelement, but how does one load it within the button click?

Can one point me to a tutorial?

<MediaElement  Height="113" 
               HorizontalAlignment="Left" 
               Name="mediaElement1" 
               Width="177" Source="giffy.gif" 
               LoadedBehavior="Play" 
               Stretch="Fill" SpeedRatio="1" IsMuted="False" />

Solution

  • I have used this one and it is easily installed via the Nuget installer into the project.

    Nuget WpfAnimatedGif

    Their github page WPF Animated GIF specifies how to set it to loop x number of times.