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?
有没有一种实用的方法让我们慢慢地将WinForms应用程序发展为WPF,而不会为奇怪的互操作场景创建支持梦魇?
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...
我们有一个大型战舰灰色WinForms应用程序,大约60-75个用户的内部组使用。我们开始遇到在WPF中使用应用程序可以看到一些好处的地方,但这还不足以证明大型项目完全重写它的合理性。应用程序中的所有屏幕都是自包含的WinForms用户控件,WinForms应用程序只是一个处理菜单,打开/关闭表单,提供一些共享帮助方法等的shell ...
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.
到目前为止,我们最好的想法是将shell应用程序转换为WPF,然后在其中托管WinForms用户控件。我们认为随后可以转换用户控件,将这些更改与具有足够业务价值的计划相结合,以支持其他工作。我担心互操作性能如何以及它将如何影响性能。我也关注我们如何过渡到应用程序的新外观。让shell应用程序看起来很时髦,然后在其中托管旧的战舰灰色用户控件似乎很奇怪,在WPF中创建shell应用程序并使它看起来就像在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.
如果其中一个Caliburn,Prism或其他类似的框架可以缓解过渡,我们也愿意探索这些选择。
2 个解决方案
#1
11
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.
我们处于类似情况并选择了以下路径:开始时我们开始在应用程序shell(仍然是WinForms)中托管一些WPF窗口。当然有一些明显的差异,但我们通过降低新窗口故意减少差异。我们认为,当我们转换剩余的窗口/控件时,将更容易“升级”到更生动的体验,因为UI将完全是WPF,我们可以让图形设计师基于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!
我们现在已经达到了大多数窗口都是WPF的程度。我们已经开始将WinForms shell应用程序转换为托管其余WinForms的基于WPF的shell应用程序。我们的颜色有点暗淡,但是用户已经开始注意到它们之间的区别,尽管它很小,但我们的用户仍然喜欢渐进的积极变化。不会太久,我们将退休最后的WinForm。这将是我们让我们的图形设计师脱离皮带的关键!
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.
至于性能:我当然不能做出一般性陈述,因为它在很大程度上取决于你的特定控件/窗口。在我们的产品(几百个窗口)中,我们没有发现任何与WPF和WinForms混合相关的重大性能问题。
We didn't look into any of the frameworks, so I'm afraid I cannot comment on those.
我们没有调查任何框架,所以我担心我不能对这些框架发表评论。
#2
4
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.
很棒的问题,目前WPF中的大部分工作都涉及将旧的WinForms应用程序转换为WPF。根据我的经验,最佳案例场景是根据旧的应用程序/要求从头开始构建应用程序。幸运的是,我参与了一个项目的一部分,我们从头开始重新编写应用程序,我确信这需要花费更少的时间/投资,然后将两者混合使用。
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 -
在我目前的项目(这是一个过去10年的大型项目)中,我们正在逐个模块地转换应用程序。幸运的是,我们的应用程序包含各种较小的应用程序,因此逐个转换它们会更容易。在你的情况下,我会说你确定可以完全转换为WPF的区域并开始在WPF中构建它们,如下所示 -
Windows Forms – WPF Interoperability FAQ: http://windowsclient.net/learn/integration.aspx
Windows窗体 - WPF互操作性常见问题解答: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.
我还建议使用一些工具将Windows窗体转换为XAML(WPF);这肯定会帮助你节省一些时间。
Windows Forms to WPF converter: http://wf2wpf.codeplex.com/
Windows窗体到WPF转换器:http://wf2wpf.codeplex.com/
Windows Forms to XAML Converter: http://www.ingeniumsoft.com/Products/WinForm2XAML/tabid/63/language/en-US/Default.aspx
Windows Forms to XAML Converter:http://www.ingeniumsoft.com/Products/WinForm2XAML/tabid/63/language/en-US/Default.aspx
Windows Forms to Windows Presentation Foundation Converter: http://www.spiderwan.com/spiderwan/ConvertWinFormToWPF/WinFormToWPF.aspx
Windows窗体到Windows Presentation Foundation转换器:http://www.spiderwan.com/spiderwan/ConvertWinFormToWPF/WinFormToWPF.aspx
#1
11
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.
我们处于类似情况并选择了以下路径:开始时我们开始在应用程序shell(仍然是WinForms)中托管一些WPF窗口。当然有一些明显的差异,但我们通过降低新窗口故意减少差异。我们认为,当我们转换剩余的窗口/控件时,将更容易“升级”到更生动的体验,因为UI将完全是WPF,我们可以让图形设计师基于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!
我们现在已经达到了大多数窗口都是WPF的程度。我们已经开始将WinForms shell应用程序转换为托管其余WinForms的基于WPF的shell应用程序。我们的颜色有点暗淡,但是用户已经开始注意到它们之间的区别,尽管它很小,但我们的用户仍然喜欢渐进的积极变化。不会太久,我们将退休最后的WinForm。这将是我们让我们的图形设计师脱离皮带的关键!
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.
至于性能:我当然不能做出一般性陈述,因为它在很大程度上取决于你的特定控件/窗口。在我们的产品(几百个窗口)中,我们没有发现任何与WPF和WinForms混合相关的重大性能问题。
We didn't look into any of the frameworks, so I'm afraid I cannot comment on those.
我们没有调查任何框架,所以我担心我不能对这些框架发表评论。
#2
4
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.
很棒的问题,目前WPF中的大部分工作都涉及将旧的WinForms应用程序转换为WPF。根据我的经验,最佳案例场景是根据旧的应用程序/要求从头开始构建应用程序。幸运的是,我参与了一个项目的一部分,我们从头开始重新编写应用程序,我确信这需要花费更少的时间/投资,然后将两者混合使用。
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 -
在我目前的项目(这是一个过去10年的大型项目)中,我们正在逐个模块地转换应用程序。幸运的是,我们的应用程序包含各种较小的应用程序,因此逐个转换它们会更容易。在你的情况下,我会说你确定可以完全转换为WPF的区域并开始在WPF中构建它们,如下所示 -
Windows Forms – WPF Interoperability FAQ: http://windowsclient.net/learn/integration.aspx
Windows窗体 - WPF互操作性常见问题解答: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.
我还建议使用一些工具将Windows窗体转换为XAML(WPF);这肯定会帮助你节省一些时间。
Windows Forms to WPF converter: http://wf2wpf.codeplex.com/
Windows窗体到WPF转换器:http://wf2wpf.codeplex.com/
Windows Forms to XAML Converter: http://www.ingeniumsoft.com/Products/WinForm2XAML/tabid/63/language/en-US/Default.aspx
Windows Forms to XAML Converter:http://www.ingeniumsoft.com/Products/WinForm2XAML/tabid/63/language/en-US/Default.aspx
Windows Forms to Windows Presentation Foundation Converter: http://www.spiderwan.com/spiderwan/ConvertWinFormToWPF/WinFormToWPF.aspx
Windows窗体到Windows Presentation Foundation转换器:http://www.spiderwan.com/spiderwan/ConvertWinFormToWPF/WinFormToWPF.aspx