核心提示:wpf 程序需要动态显示gif图片,试过MediaElement、Image 以及winform 的 pictureBox,要不图片显示不出来,要不显示出来不动,亲测以下方法可用。1.打开vs 工具-...
wpf 程序需要动态显示gif图片,试过MediaElement、Image 以及winform 的 pictureBox,要不图片显示不出来,要不显示出来不动,亲测以下方法可用。
1.打开vs 工具->库程序包管理工具->程序包管理器控制台
2. PM> Install-PackageWpfAnimatedGif
3.要使用这个包需要加入新的命名空间
<Window x:Class="Meeting.MainWindow" xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" xmlns:gif="https://wpfanimatedgif.codeplex.com" Icon="/images/icon.ico" Title=" MainWindows" Height="610" Width="900" > <Grid> <Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" /> </Grid> </Window>