Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 585
Vincent Hubert Avatar asked Jun 02 '14 18:06

Vincent Hubert


1 Answers

The short answer for those that don't want to do the comparison themselves is that a WPF .csproj file contains an addition property:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Just put that in the first <PropertyGroup>...</PropertyGroup> section, it shouldn't matter where.

The meaning of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548} is that this is a WPF project, and {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} indicates a C# project. You can learn more about project type guids from this SO question.

like image 133
othp Avatar answered Oct 13 '22 19:10

othp