Hello, I was looking for information because I had the same problem, and in the end I found your question right after I found an answer (rs).
Well, to put a Gif in a WPF window, I used a <MediaElement>
. In my case, something like this:
<MediaElement x:Name="mediaElement" MediaEnded="mediaElement_MediaEnded" HorizontalAlignment="Center" Height="200" Margin="0" VerticalAlignment="Center" Width="200" Source="CaminhoAbsolutoPara/Gif.gif" Stretch="Fill" UnloadedBehavior="Manual" LoadedBehavior="Play"/>
And then I created an event for the Gif to go into a loop. In the MediaEnded event I put a code like this:
private void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
{
mediaElement.Position = new TimeSpan(0, 0, 1);
mediaElement.Play();
}
Well, just a little explanation for the code: the Source path to the Gif should be absolute. For example: C: //...image.gif
In the event, the name mediaElement.Position
... and mediaElement.Play
, is the name you gave to your MediaElement in the x:Name="mediaElement"
Since the HorizontalAlignment="Center" Height="200" Margin="0" VerticalAlignment="Center" Width="200"
properties are something personal to you.
I hope I have been able to help you. Thanks.