What control type should I use - Image
, MediaElement
, etc.?
相关问题
- Generic Generics in Managed C++
- VNC control for WPF application
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
相关文章
- .net中MessageBox.Show使用问题
- IdentityServer 报错:"idp claim is missing"
- 在 IdentityServer 中如何给 id token 添加更多信息
- WPF:如何在Trigger里修改Orientation?
- IdentityServer 的 Selector 在哪个 nuget 包
- 使用 IdentityServer 的项目遭遇错误:"IDX20803: Unable to obt
- ASP.NET Core ConfigureServices 中从 appsettings.json
- WPF aforge 怎么做一个 圆形的播放器
I use this library: http://wpfanimatedgif.codeplex.com/
First, install library into your project (using Package Manager Console):
Then, use this snippet into XAML file:
I hope helps.
Source: http://wpfanimatedgif.codeplex.com/
I am not sure if this has been solved but the best way is to use the WpfAnimatedGid library. It is very easy, simple and straight forward to use. It only requires 2lines of XAML code and about 5 lines of C# Code in the code behind.
You will see all the necessary details of how this can be used there. This is what I also used instead of re-inventing the wheel
How about this tiny app: Code behind:
XAML:
I post a solution extending the image control and using the Gif Decoder. The gif decoder has a frames property. I animate the
FrameIndex
property. The eventChangingFrameIndex
changes the source property to the frame corresponding to theFrameIndex
(that is in the decoder). I guess that the gif has 10 frames per second.Usage example (XAML):
I had this issue, until I discovered that in WPF4, you can simulate your own keyframe image animations. First, split your animation into a series of images, title them something like "Image1.gif", "Image2,gif", and so on. Import those images into your solution resources. I'm assuming you put them in the default resource location for images.
You are going to use the Image control. Use the following XAML code. I've removed the non-essentials.
I have try all the way above, but each one has their shortness, and thanks to all you, I work out my own GifImage:
Usage:
As it would not cause memory leak and it animated the gif image own time line, you can try it.