Search code examples
c#.netwpfwinforms

Convert csproj file from winform to wpf


I have a Winform app that has one very simple form, a program.cs main file and about 60 back-end .cs files. I want to convert the project to a WPF application. Looking here didn't show anything close to what I want to do.

I need to

  • Convert the csproj file so it will allow me to add WPF windows
  • That conversion to be done "in place" to keep my source control tidy and avoid the trouble of adding back all the back end files in their proper folders, add the references to external dependencies, etc.
  • Create one empty mainwindow.xaml (+.cs) file that I will manually fill with the appropriate controls.

Then, I will manually split the content of the old forms file between the view and the viewmodel files.

Any way of doing that easier than starting from scratch?

EDIT: I would rather not host the new WPF ui into the old winforms shell but replace the current forms application by a wpf one.

EDIT2: I do not want to convert the entire project and the architecture to WPF (as it was asked and answered several times on SO), I totally understand that these are 2 different framework and I am totally willing to do the change manually. I want to convert the csproj so it will compile as a WPF app instead of a Forms app.


Solution

  • It seems from your edit2 that you just want to change the project type from "Winforms" to "WPF" without changing any of the project items. I don't know why you want to do this, but try creating an empty Winforms project, then creating an empty WPF project, then comparing the two project files.

    Whatever the difference is between the two empty projects, make that change to your existing Winforms project.