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 怎么做一个 圆形的播放器
Its very simple if you use
<MediaElement>
:Here is my version of animated image control. You can use standard property Source for specifying image source. I further improved it. I am a russian, project is russian so comments are also in Russian. But anyway you should be able understand everything without comments. :)
I modified Mike Eshva's code,And I made it work better.You can use it with either 1frame jpg png bmp or mutil-frame gif.If you want bind a uri to the control,bind the UriSource properties or you want bind any in-memory stream that you bind the Source propertie which is a BitmapImage.
This is a custom control. You need to create it in WPF App Project,and delete the Template override in style.
Previously, I faced a similar problem, I needed to play
.gif
file in your project. I had two choices:using PictureBox from WinForms
using a third-party library, such as WPFAnimatedGif from codeplex.com.
Version with
PictureBox
did not work for me, and the project could not use external libraries for it. So I made it for myself throughBitmap
with helpImageAnimator
. Because, standardBitmapImage
does not support playback of.gif
files.Full example:
XAML
Code behind
Bitmap
does not support URI directive, so I load.gif
file from the current directory.Small improvement of
GifImage.Initialize()
method, which reads proper frame timing from GIF metadata.Basically the same PictureBox solution above, but this time with the code-behind to use an Embedded Resource in your project:
In XAML:
In Code-Behind: