0

I'm using WpfAnimatedGif in order to display a simple loading gif while the program runs through a database. The issue is that the gif will run while in preview mode, but during runtime the gif is just a static image. Could it be with how I'm saving the image (it's saved as a .gif file) or with how it's being loaded or am I just over thinking this?

<Window x:Class="SDITicketAudit.UIWindows.WaitingScreen"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:gif="http://wpfanimatedgif.codeplex.com"
    gif:ImageBehavior.AnimateInDesignMode="True"
    Title="Running Audits" ResizeMode="CanMinimize" Height="118.071" Width="245.6"
    WindowStartupLocation="Manual" Left="50" Top="100">
<Grid>
    <TextBlock x:Name="loadUpdates" HorizontalAlignment="Center" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="44" Width="220"/>
    <Image gif:ImageBehavior.RepeatBehavior="Forever"
           gif:ImageBehavior.AnimatedSource="pack://application:,,,/Resources/ajax-loader.gif" />
</Grid>

1 Answers1

0

Try going with the simpler, cleaner solution found here:

<MediaElement LoadedBehavior="Play"
              Source="pack://application:,,,/Resources/ajax-loader.gif"
              Stretch="None"/>

The only thing I can guess is wrong with your snippet is dimensions are set, the library you used has a bug or your Uri is invalid (so my solution wouldn't work either)

Community
  • 1
  • 1
Kcvin
  • 5,073
  • 2
  • 32
  • 54
  • I copied over what you suggested and the gif is now unmoving in the preview and not showing up at all during runtime. The gif is in my Resources folder for the project and its build action is set to Resource. – TheDumpiest Dec 23 '15 at 16:24
  • @CameronMeyers [Looks like](http://blogs.msdn.com/b/codefx/archive/2013/12/19/sample-of-dec-18th-how-to-show-gif-animation-in-wpf.aspx) GIF support is is deprecated for WPF. It sounds like if you copy the file to the output folder and use an file path (AbsoluteUri) as the source it might work. – Kcvin Dec 23 '15 at 16:33
  • I answer [this](http://stackoverflow.com/a/34419280/1144624) question yesterday where a user was using `MediaElement`, so it should work. By the way, no need to view the GIF in design mode, you gain no advantage doing so. – Kcvin Dec 23 '15 at 16:35
  • Hence why I was trying to use WpfAnimatedGif, as it _should_ allow for gif usage and other's on here have talked about its success. – TheDumpiest Dec 23 '15 at 16:52
  • @TheDumpiest have your tried using relative uri path? Shown in the [demo](https://github.com/thomaslevesque/WpfAnimatedGif/blob/master/WpfAnimatedGif.Demo/WpfAnimatedGif.Demo.csproj) of the WpfAnimatedGif, his .gifs are set to resource but doesn't use pack Uri notation – Kcvin Dec 23 '15 at 17:01
  • Shoot I didn't even see that! Thank you. I'll take a look through and see what I can find! – TheDumpiest Dec 23 '15 at 17:29