Display animated GIFs in Metro

Is there a control to display an animated gif in the Windows Store (Metro) app in Windows 8? I use C # and XAML with data binding.

+3
source share
6 answers

The Image control does not support animated GIFs. You will need to extract frames and animate them on your own timer.

You should take a look at this link, which can help you in resolving your issue:

http://advertboy.wordpress.com/2012/05/08/animated-gifs-in-xamlc/

+2
source

You cannot display an animated gif in a grid. However, you can display an animated present in the webview controller.

+2
source

Note only: you can use the BitmapDecoder class to read GIF frames, create animation for the storyboard.

I have an example of a Windows 8 user control on my blog: http://www.henrikbrinch.dk/Blog/2013/02/21/Windows-8---GIF-animations--the-RIGHT-way

+1
source

I managed to display the gif in a windows 8 metro application by simply translating the gifs into jpegs and then starting an endless loop.

The code is as follows:

public async void UpdateImage () {

await Task.Delay(300); var frame = this.Frame.CurrentSourcePageType.Name; if (frame != ("CURRENTFRAME")) return; if (count <= 4) { var img = (BitmapImage) Resources["bitmap" + count]; imgTap.Source = img; UpdateLayout(); count++; UpdateImage(); } else { count = 1; UpdateImage(); } } 

So basically I save the converted jpegs in my page.resources and then call them as bitmap1, bitmap2 .. etc. I check if the current frame is the frame that the gif should display, otherwise the gif code will work in the background for all the time, which is a waste of memory and processor. Just call this method for any of the Loaded method, and it should work fine.

+1
source

This is probably too much, but you can try using WebView to display GIFs. However, the WebView control introduces its own set of headaches, so if you are not ready to deal with these headaches, I would recommend avoiding it if you should not use it.

0
source

If I'm right, Silverlight does not support GIF and Metro applications based on the Silverlight platform. Therefore, does not contain support for GIF images natively. However, you can use third-party controls such as http://www.componentone.com/SuperProducts/ImageSilverlight/ .

-one
source

All Articles