WPF添加GIF动画

一:XamlAnimatedGif

xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"

<Image gif:AnimationBehavior.SourceUri="..\Images\startup.gif" gif:AnimationBehavior.AnimateInDesignMode="True" gif:AnimationBehavior.RepeatBehavior="Forever"  ></Image>

踩坑:图片属性需设置为  资源  类型

 

二:MediaElement

<MediaElement Name="mediaPlayer" Source="..\Images\startup.gif">

踩坑:加载动画时会加载完整后再播放,占用内存;可以播放完后 mediaPlayer上级.Child=null释放内存

 

三:wpfanimatedgif

xmlns:gif="http://wpfanimatedgif.codeplex.com"

<Image gif:AnimationBehavior.SourceUri="..\Images\startup.gif" gif:AnimationBehavior.AnimateInDesignMode="True" ></Image>

踩坑:与MediaElement机制一致;但会不断加载,重复循环播放;如果不停止播放则内存无限占用

 

以上为短暂测试后结果

posted @ 2022-11-17 10:48  谷玥  阅读(792)  评论(0)    收藏  举报