将大型C#winforms应用程序升级到WPF的最简单方法是什么 [英] What is the easiest way to upgrade a large C# winforms app to WPF

查看:75
本文介绍了将大型C#winforms应用程序升级到WPF的最简单方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在大型C#应用程序(大约450,000行代码)上工作,我们经常遇到桌面堆和GDI处理泄漏的问题。 WPF解决了这些问题,但是我不知道什么是升级的最佳方法(我预计这将花费很长时间)。该应用程序只有几种形式,但是它们可以包含以编程方式确定的许多不同的用户控件集。

I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contain many different sets of user-controls which are determined programatically.

这是公司内部的应用程序,因此我们的发布周期非常长。短(通常为3周的发布周期)。

This is an internal company app so our release cycles are very short (typically 3 week release cycle).

是否有一些逐步升级的路径,还是我们必须付出巨大的努力?

Is there some gradual upgrade path or do we have to take the hit in one massive effort?

推荐答案

您可以从创建WPF主机开始。

You can start by creating a WPF host.

然后您可以使用< WindowsFormHost />控制以托管当前应用程序。然后,我建议在WPF中创建一个新控件库。一次可以创建一个控件(我建议将它们设置为自定义控件,而不是用户控件)。在每个控件的样式内,您可以先使用< ElementHost />控件以包括旧的 Windows窗体控件。然后,您可以花时间重构和重新创建每个控件作为完整的WPF。

Then you can use the <WindowsFormHost/> control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style for each control, you can start with using the <ElementHost/> control to include the "old" windows forms control. Then you can take your time to refactor and recreate each control as complete WPF.

我认为创建控件包装并为该应用程序设计WPF主机仍然需要初步的努力。我不确定应用程序的大小或用户控件的复杂性,因此不确定要为您付出多少努力。相对而言,以这种方式在WPF中启动和运行应用程序要花费的精力明显少得多,而且快得多。

I think it will still take an initial effort to create your control wrappers and design a WPF host for the application. I am not sure the size of the application and or the complexity of the user controls, so I'm not sure how much effort that would be for you. Relatively speaking, it is significantly less effort and much faster to get you application up and running in WPF this way.

我不会那样做而忘记它,因为您可能会遇到控件相互重叠的问题(Windows窗体在WPF中不能很好地发挥作用,尤其是以及透明胶片和其他视觉效果)

I wouldn't just do that and forget about it though, as you may run into issues with controls overlaying each other (Windows forms does not play well with WPF, especially with transparencies and other visuals)

请向我们介绍该项目的状态,如果您需要更具体的指导,请提供更多技术信息。谢谢:)

Please update us on the status of this project, or provide more technical information if you would like more specific guidance. Thanks :)

这篇关于将大型C#winforms应用程序升级到WPF的最简单方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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