站内搜索:
首页 >> 前端 >> 内容
wpf程序动态显示gif图片的方法

时间:2017/10/25 10:07:13

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>

 

  • 上一篇:获取元素样式的三种方法
  • 下一篇:如何查看HTML源码?HTML文本格式化教程
  • 返回顶部