tags:

views:

1300

answers:

5

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.

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?

+3  A: 

Do you use a lot of User controls for the pieces? WPF can host winform controls, so you could piecewise bring in parts into the main form.

Lou Franco
Yes, (I edited controls => user-controls.
Chris
You can add your user controls to a WPF form. Then translate them as needed to WPF
Lou Franco
+2  A: 

WPF allows you to embed windows forms user controls into a WPF application, which may help you make the transition in smaller steps.

Take a look at the WindowsFormsHost class in the WPF documentation.

Isak Savo
+1  A: 

There is a very interesting white paper on migrating a .NET 2.0 winform application toward WPF, see Evolving toward a .NET 3.5 application

Paper abstract: In this paper, I’m going to outline some of the thought processes, decisions and issues we had to face when evolving a Microsoft .NET application from 1.x/2.x to 3.x. I’ll look at how we helped our client to adopt the new technology, and yet still maintained a release schedule acceptable to the business.

Joannes Vermorel
+9  A: 

You can start by creating a WPF host.

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.

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.

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 :)

Phobis
+2  A: 

I assume that you are not just looing for an ElementHost to put your vast Winforms app. That is anyway not a real porting to WPF. Consider the answers on this Thread http://stackoverflow.com/questions/109620/what-are-the-bigger-hurdles-to-overcome-migrating-from-winforms-to-wpf, It will be very helpfull.

Jobi Joy