记录一个WPF播放GIF控件

在项目中有次听别人说因为GIF播放引起了重大BUG。今天看到了一个gif不知好用否,时间紧,待后面测试吧。

仓库地址:https://github.com/XamlAnimatedGif/WpfAnimatedGif

Nuget 包:WpfAnimatedGif

xaml使用

 <Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" />

<Image gif:ImageBehavior.RepeatBehavior="3x"
       gif:ImageBehavior.AnimatedSource="Images/animated.gif" />

code 使用

var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(fileName);
image.EndInit();
ImageBehavior.SetAnimatedSource(img, image);

分析总结:???

 

posted @ 2022-09-09 14:00  stweily  阅读(116)  评论(0编辑  收藏  举报