在Windows窗体中使用System.Windows.Media命名空间而不是WPF,是否会影响性能? [英] using System.Windows.Media Namespace in Windows Forms, not WPF, does it make difference in performance?

查看:152
本文介绍了在Windows窗体中使用System.Windows.Media命名空间而不是WPF,是否会影响性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GDI +很慢。

System.Windows.Media更快。



我想在Windows中使用System.Windows.Media命名空间表格,而不是WPF。

与WPF相比,它的性能有所不同吗?

我认为无论在哪里使用都没有区别。

什么是对的?

GDI+ is slow.
System.Windows.Media is faster.

I wanna use System.Windows.Media Namespace in Windows Forms, not in WPF.
Does it make difference in performance in compare to WPF?
I think it is no matter where to use and makes no difference.
What is right?

推荐答案

这是完全没有意义的尝试使用 System.Windows .Media System.Windows.Forms 中。 System.Windows中有两个根本不同的UI库: System.Windows.Forms 和WPF(其余的 System.Windows )。



表格使用Windows API,包括Windows消息,基于Windows HWND和GDI的Windows控件。



WPF不使用任何内容(消息在处理原始用户输入事件的最顶层窗口的事物层中使用,所有其他UI元素与Windows操作系统完全无关,并且不使用Windows消息传递机制) 。它几乎脱离了Windows API的大多数方面,并且基于DirectX。



这两种方法非常不同,不能一起使用。更准确地说,不是在媒体或图形层面。有两个互操作工具:由Forms控件托管WPF控件,以及由WPF UI元素托管Forms控件。我不是在详细讨论这种互操作,因为它与你的问题无关。



间接地,我刚才提到的方式,你可以使用WPF媒体Windows窗体,但是你的问题被简化为WPF和Forms之间的性能比较。 一般来说,WPF表现更好,但这取决于你做什么和如何做,很多因素。你为什么不自己比较一下这个表现呢?只有,不需要在Forms中使用WPF ,因为创建WPF UI会更容易。但是,以防万一,这是在Windows窗体中托管WPF复合控件的链接: http://msdn.microsoft.com/en-us/library/ms742215%28v=vs.110%29.aspx [ ^ ]。



-SA
This is totally pointless to try to use System.Windows.Media in System.Windows.Forms. There are two fundamentally different UI libraries inside System.Windows: System.Windows.Forms and WPF (the rest of System.Windows).

Forms uses Windows API, including windows messages, Windows controls based on Windows HWND and GDI.

WPF does not use anything of that (messages are using in a thing layer of the topmost window where raw user input events are handled, all other UI elements are totally unrelated to Windows OS and don't use Windows messaging mechanism). It is pretty much detached from most aspects of Windows API and is based on DirectX.

These two approaches are very different and are not used together. More exactly, not at the level of media or graphic. There are two interop facilities: hosting a WPF control by a Forms control, and a Forms control by a WPF UI element. I'm not discussing this kind of interop in detail, because it's irrelevant to your question.

Indirectly, the way I just mentioned above, you can use WPF media in Windows forms, but then your question is reduced to the performance comparison between WPF and Forms. Generally, WPF performance is better, but it depends on what and how you are doing things, many factors. Why won't you compare the performance yourself? Only, there is no need to use WPF in Forms, as it would be easier just to create a WPF UI. But, just in case, this is the link for hosting a WPF composite control in Windows Forms: http://msdn.microsoft.com/en-us/library/ms742215%28v=vs.110%29.aspx[^].

—SA


这篇关于在Windows窗体中使用System.Windows.Media命名空间而不是WPF,是否会影响性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆