Upgrading a WinForms app to WPF

Open project manifest file (one with the .csproj extension) and modify PropertyGroup node (the one without Condition element) as below:

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

After this modification restart VS. Now you can add WPF window or other WPF elements. You may also have to add references System.Xaml, PresentationCore and PresentationFramework.


I don't know for certain what in the project file informs Visual Studio what type of project is being used, but my guess is the "ProjectTypeGuids" is key.

My WPF projects have this:

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

Here is a link I found which describes the guids and what kind of project they represent. You'll notice that the guid starting with "60DC" matches the list in the link for WPF applications.


Sailing Judo's answer worked for me to convert a WinForms project into a WPF, but did not describe in detail what is needed;

  1. Open the csproj file for the project you want to convert.
  2. Search for the string <ProjectTypeGuids> - most likly it will not exist.
  3. Add the following within the tag of the project file. If you have multiple PropertyGroup tags, use the one without a Condition attribute (e.g. the default properties).

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

  4. Save - if you have the project open VS will ask to reload the project.

From what I see and test, I can now easily add WPF Windows and WinForms. My older WinForms also work without problems.


Sadly no.

WPF and Windows Forms projects aren't very compatible.

  • Try to extract as much fussiness logic code into a class library
  • Create a new blank solution
  • Add a new WPF project to the solution
  • Add the class library project to the solution
  • Set the class library as a dependency of the WPF project
  • Recreate the windows in WPF

Hope this works for you.

Best of luck with this endeavor!