Display GIF in a WP7 application with Silverlight

后端 未结 6 758
一向
一向 2020-11-27 06:10

I would like to display gif in my WP7 application. Is there some way to achieve this ?

I\'ve tryed this one http://imagetools.codeplex.com/ but can\'t make it workin

6条回答
  •  醉话见心
    2020-11-27 06:32

    I struggled to get the accepted answer working. The following solution worked for me to display a static gif.

        public ImageResponse(string imageUrl)
        {
            InitializeComponent();
    
            ImageTools.IO.Decoders.AddDecoder();
    
            var imageResponse = new ExtendedImage();
            imageResponse.UriSource = new Uri(imageUrl);
    
            imageResponse.LoadingCompleted += this.ImageResponseLoadingCompleted;
        }
    
        private void ImageResponseLoadingCompleted(object sender, EventArgs e)
        {
            var imageResponse = (ExtendedImage)sender;
    
            Classes.Util.UiThread.Invoke(() =>
                {
                    this.ImageResponse.Source = imageResponse.ToBitmap();
                });
        }
    

    Classes.Util.UiThread is a helper class I use to call the UI Thread

    this.ImageResponse is a standard image control

提交回复
热议问题