I have a side project that I wrote a few years ago in WinForms. To better help me learn WPF, I would like to rewrite it in WPF. Ideally, I would like to just modify the curr
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.
Sadly no.
WPF and Windows Forms projects aren't very compatible.
Hope this works for you.
Best of luck with this endeavor!
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;
csproj
file for the project you want to convert.<ProjectTypeGuids>
- most likly it will not exist.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>
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.