WinForms 到 WPF - 我们如何从这里到达那里?
是否有一种实用方法可以让我们慢慢地将 WinForms 应用程序发展到 WPF,而不会给我们自己带来奇怪的互操作场景的支持噩梦?
背景信息:
我们有一个大型战舰灰色 WinForms 应用程序,大约 60-75 个用户的内部组大量使用该应用程序。我们开始遇到一些地方,我们可以看到在 WPF 中使用应用程序可以带来一些好处,但这还不足以证明大型项目完全重写它是合理的。应用程序中的所有屏幕都是独立的 WinForms 用户控件,WinForms 应用程序只是一个处理菜单、打开/关闭表单、提供一些共享帮助器方法等的 shell。
到目前为止,我们最好的想法是的方法是将 shell 应用程序转换为 WPF,然后在其中托管 WinForms 用户控件。我们认为,随着时间的推移,我们可以转换用户控件,将这些更改与具有足够业务价值以支持额外工作的计划联系起来。我担心互操作的效果如何以及它将如何影响性能。我还担心我们如何过渡到应用程序的新外观。让 shell 应用程序看起来很时髦,然后在其中托管旧的战舰灰色用户控件,这似乎很奇怪,而且在 WPF 中创建 shell 应用程序并使其看起来就像在 WinForms 中一样,这似乎也很奇怪。
如果 Caliburn、Prism 或其他类似框架之一能够简化过渡,我们也愿意探索这些选项。
Is there a practical way for us to slowly evolve a WinForms application to WPF without creating a support nightmare for ourselves with strange interop scenarios?
Background info:
We have a large battleship gray WinForms application that is heavily used by an internal group of about 60-75 users. We're starting to run into places where we could see some benefit from having the app in WPF, but it's not enough to justify a large project to completely re-write it. All of the screens in the app are self-contained WinForms user controls and the WinForms app is just a shell that handles menuing, opening/closing forms, provides some shared helper methods, etc...
Thus far, the best idea we've had is to convert the shell application to WPF and then host the WinForms user controls inside it. We thought that we could then convert the user controls over time, tieing those changes to initiatives that have enough business value to support the additional work. I'm concerned about how well the interop works and how it will impact performance. I'm also concerned about how we transition to a new look for the app. It would seem odd to make the shell app look snazzy and then have old battleship gray user controls hosted inside it and it also seems odd to create the shell app in WPF and make it look just like it did in WinForms.
If one of the Caliburn, Prism, or another similar framework would ease the transition, we'd be open to exploring those options as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们遇到了类似的情况,并选择了以下路径:一开始,我们开始在应用程序 shell 中托管一些 WPF 窗口(仍然是 WinForms)。当然,存在一些明显的差异,但我们通过淡化新窗口来故意减少差异。我们认为,当我们转换剩余的窗口/控件时,将更容易“升级”到更生动的体验,因为 UI 将完全是 WPF,并且我们可以让图形设计人员基于 XAML 发挥其魔力。
我们现在已经到了大多数窗口都是 WPF 的地步。我们已经开始将 WinForms shell 应用程序转换为托管其余 WinForms 的基于 WPF 的 shell 应用程序。我们仍然有一些暗淡的颜色,但用户已经开始注意到差异,尽管差异很小,但我们的用户仍然喜欢增量的积极变化。不久之后,我们将淘汰最后一个 WinForm。这就是我们让图形设计师摆脱束缚的时刻!
至于性能:我当然不能做出一般性的陈述,因为它在很大程度上取决于您的特定控件/窗口。在我们的产品(数百个窗口)中,我们没有发现任何与 WPF 和 WinForms 混合相关的重大性能问题。
我们没有研究任何框架,所以恐怕我无法对这些框架发表评论。
We were in a similar situation and chose the following path: At the beginning we started to host a few WPF windows in the application shell (still WinForms). Of course there was some visible difference but we reduced the difference deliberately by toning down the new windows. We figured that by the time we would convert the remaining windows/controls it will be easier to "upgrade" to a more vivid experience since the UI will be entirely WPF and we can involve a graphical designer to work their magic based on XAML.
We have now reached the point where the majority of the windows are WPF. We have started the process of converting the WinForms shell app into a WPF based shell application hosting the remaining WinForms. We sill have sort of dull colors but users have started to notice the difference and although it is small our users still like the incremental positive change. Not too long and we will retire the last WinForm. That will be the point when we let our graphical designers off the leash!
As to performance: I can certainly not make a general statement as it heavily depends on your particular controls/windows. In our product (several hundred windows) we haven't found any significant performance issue related to the mix of WPF and WinForms.
We didn't look into any of the frameworks, so I'm afraid I cannot comment on those.
很好的问题,目前 WPF 中的大部分工作都涉及将旧的 WinForms 应用程序转换为 WPF。根据我的经验,最好的情况是根据旧的应用程序/需求从头开始构建应用程序。幸运的是,我参与了一个项目,我们从头开始重新编写了应用程序,我确信与混合两者相比,花费的时间/投资更少。
我个人认为,如果我们尝试将两者混合,就会造成混乱。另一点是,高效地设计混合应用程序将很困难。
在我当前的项目(这是一个过去 10 年运行的大型项目)中,我们正在逐个模块地转换应用程序模块。对我们来说幸运的是,我们的应用程序由各种较小的应用程序组成,因此将它们一一转换更容易。就您而言,我想说您确定可以完全转换为 WPF 的区域并开始在 WPF 中构建它们,如此处建议的 -
Windows 窗体 – WPF 互操作性常见问题解答:
http://windowsclient.net/learn/integration.aspx
我还建议使用一些用于将 Windows 窗体转换为 XAML(WPF) 的工具;这肯定会帮助您节省一些时间。
Great question, at present most of the work in WPF deals with converting old WinForms application to WPF. From my experience best case scenario is to build the application from scratch based on old application/requirements. Fortunately I have been part of a project where we have re-written the application from scratch and I am sure that it took less time/investment then mixing the two.
I personally feel that it would have created a mess if we had tried mixing the two. Another point is that it will be tough to design the mixed application efficiently.
In my current project (which is a huge project running from past 10 years) we are converting the application module by module basis. Fortunately for us our application consists of various smaller applications, so converting them one by one is easier. In your case I would say that you identify the areas which can be totally converted to WPF and start building them in WPF, as suggested here -
Windows Forms – WPF Interoperability FAQ:
http://windowsclient.net/learn/integration.aspx
I would also suggest to use some tools for converting the windows forms to XAML(WPF); that will surely help you in saving some time.