使用一个ElementHost的承载一个WPF用户控件在WinForm应用程序的任何缺点?控件、应用程序、缺点、用户

2023-09-04 02:54:56 作者:妳終于露出妳原有的正面目

好奇,如果有任何缺点使用的 ElementHost的来举办一个WPF用户控件在WinForm应用程序?

Curious if there are any disadvantages to using an ElementHost to host a WPF UserControl in a Winform application?

我问,因为总的来说,我觉得,它需要太多的时间,我创建一个新的WPF应用程序有一个基本的接口,看起来体面。体面在这个意义上,如果我在上面创建一个新的WinForms应用程序,并抛出一些控制我结束了一个基本的界面,外观和行为相似,许多其他应用程序,但看起来并不普通。如果我做同样的事情用一个WPF应用程序,我不觉得我达到相同的结果,我结束了一个普通的应用背景为白色,除非我改变角色设计师,花费额外的时间,使它看起来有一定方法。

I ask because in general I feel that it takes to much time for me create a new WPF application with a basic interface that looks decent. Decent in the sense that if I create a new Winforms application and throw some controls on it I end up with a basic interface that looks and behaves similar to many other applications but doesn't look plain. If I do the same thing with a WPF application I don't feel I achieve the same results, I end up with a "plain" application with a white background unless I change roles to designer and spend extra time to make it look a certain way.

然而,有这样的情况WPF期望我为它的相对容易创建程式化的接口。考虑一个视频播放器的控制;在WPF我可以创造的东西,看起来非常漂亮和自定义,但花更少的时间和精力比一个WinForms控制。在这种情况下,它是有道理的,我使用WPF,因为我最终花更少的时间比我有overiding的OnPaint: - )

However there are cases where WPF is desirable to me for it's relative ease of creating a stylized interface. Consider a video player control; in WPF I can create something that looks very nice and custom but took much less time and effort than a Winforms control. In these cases it makes sense for me to use WPF since I end up spending less time than I would have overiding OnPaint :-).

我意识到我使用了大量的主观方面,而且这是我背后的原始问题的理由。

I realize I'm using a lot of subjective terms but this is my reasoning behind the original question.

更新:

只是为了澄清我的视频播放控制的例子。不仅WPF给我的MediaElement 用,但如果我想说,覆盖视频播放按钮,当它被暂停或者,如果我想要一个半透明玩播放/暂停/停止/音量栏显示出来当鼠标在某个位置,WPF使得这比任何的WinForms替代简单得多。

Just to clarify my "video player control" example. Not only does WPF give me the MediaElement to play with but if I want to say, overlay a Play button on the video when it is paused or if I wanted a semi-transparent "play/pause/stop/volume" bar to show up when the mouse in in a certain location, WPF makes that much simpler than any Winforms alternative.

编辑:

也许我有一个配置选项错误或东西,但它也是令人沮丧的,当我在看一个WPF主场迎战的WinForms控制的说明部分消失。更令人沮丧的,在一个WPF物业形态pressing F1不会带你到特定的属性/事件你的。

Maybe I have a configuration option wrong or something but it's also frustrating the the "Description" section disappears when I am looking at a WPF vs. Winforms Control. Even more frustrating that pressing F1 in a WPF property form doesn't take you to the specific property/event you were on.

更新:

任何其他人?我更关心的性能影响和/或功能的限制,将通过主办WPF用户控件中的的ElementHost 。到目前为止,这听起来像有运行时的一次性开销,但就是这样吗?

Any one else? I'm more concerned about performance impacts and/or feature limitations that would be introduced by hosting the WPF UserControl in an ElementHost. So far it sounds like there is the onetime overhead of the runtime but is that all?

推荐答案

我看到一些潜在的不利因素。

I see a few potential disadvantages.

首先,你现在有两个显示用户界面的方法。这可以present问题,但从这取决于开发商接触code维修点。

First, you now have two ways of displaying UI. This can present issues from a maintenance point of view depending the developers touching the code.

二,WPF确实有一个与之相关的运行库(用于分派事件,依赖物业管理,等等,等等),但它是一个一次性的费用。如果您使用的是为少数的控制,那么你付出相当大的成本比例,它的用法。

Second, WPF does have a runtime associated with it (for dispatching events, dependency property management, etc, etc), but it's a one-time cost. If you are using that for a small number of controls, then you are paying a relatively large cost in proportion to it's usage.

我不会说这是交易断路器,这一切都依赖于你的应用程序和您的团队。

I wouldn't say these are deal-breakers, it's all dependent on your app and your team.