Animating Gif in WPF

前端 未结 3 670

I am using this code for gif Animating in seprate library and xaml code in my main project:



        
3条回答
  •  独厮守ぢ
    2020-12-06 11:05

    There is a much easier way to show an animated .gif in wpf - use the MediaElement

    Example:

    
    

    If you want the .gif to loop endlessly but it only specifies a limited amount of repeats in the .gif file, you can hook MediaEnded and just restart the animation (Be sure to set the UnloadedBehavior to Manual):

        private void myGif_MediaEnded(object sender, RoutedEventArgs e)
        {
            myGif.Position = new TimeSpan(0, 0, 1);
            myGif.Play();
        }
    

提交回复
热议问题