C# WPF中的动画GIF问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/767564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Animated GIF problem in WPF
提问by Prashant Cholachagudda
I have added above code in my WPF from which include animated GIF image, the problem is whenever form load I don't find any of the Image displayed on form, any suggestions ???
我在我的 WPF 中添加了上面的代码,其中包括动画 GIF 图像,问题是每当表单加载时,我都找不到表单上显示的任何图像,有什么建议吗???
<Image Name="imgScan" Source="Images\Pre_Scan_RealImage.gif" />
I even tried Image element shown above
我什至尝试了上面显示的图像元素
采纳答案by Prashant Cholachagudda
I fond UserControl herefor showing Animated GIFs, and guess what work just works as simple as Image control.
我喜欢在这里使用UserControl来显示动画 GIF,并猜测哪些工作与图像控制一样简单。
And thank you all
谢谢大家
Here's the same article(web post captured by the Wayback Machine)
这是同一篇文章(Wayback Machine 捕获的网络帖子)
回答by Kent Boogaart
I even tried Image element shown above
我什至尝试了上面显示的图像元素
And did it work or not? ;)
它有效还是无效?;)
The MediaElement
does not yet support pack URIs. That means you'll need to include the GIF as an external file, not a resource. That may be your problem, but you'll need to provide more info if not.
该MediaElement
尚不支持包的URI。这意味着您需要将 GIF 作为外部文件而不是资源包含在内。这可能是您的问题,但如果不是,您需要提供更多信息。
回答by PaulB
WPF at the moment doesn't natively support animated GIFs.
目前 WPF 本身不支持动画 GIF。
You can get around it by hosting the image in a PictureBox.
您可以通过在 PictureBox 中托管图像来解决它。
EDIT : Also checkout thisthread for a bit more info.
编辑:还可以查看此线程以获取更多信息。
回答by Somnath
Use XAML below
使用下面的 XAML
<MediaElement Height="30" Width="30" LoadedBehavior="Play" Source="Images\loading.gif" />
Set properties of loading.gif
设置loading.gif的属性
- BuildAction: None
- Copy to Output Directory: Copy always
- 构建操作:无
- 复制到输出目录:始终复制
It should work.
它应该工作。