While setting up my Prism WPF solution I had added a project as Class library. Just realized I want it as a WPF user control library to add resource dictionaries and other WPF related stuff. Is there a way to convert my class library project to WPF user control library project? (Project properties just has the option to convert between Console, Class library, Windows app!)
3 Answers
You need to add the following to your project file;
Under the <FileAlignment>
element
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
You may also want to insure you've the following references added within the <ItemGroup>
element;
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />

- 2,904
- 4
- 39
- 66
-
There is a missing ending slash on the last reference (System.Xaml). Without that it won't load correctly. – Jordy Boom Jun 25 '14 at 15:21
-
2Very helpful. Plz note that `
` will go at the same level as ` – dotNET Jan 02 '15 at 13:19` node, not under it as described in the answer. -
1Look [here](http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs) for other known GUIDs – LuckyLikey Jun 24 '15 at 06:50
-
Another difference I noted when comparing a Class Library to a WPF Class Library is the `
` element. For a Class Library it was `Windows` and for a WPF Class Library it was `Custom`. Once I changed this in my Class Library project file (along with `ProjectTypeGuids`), the project loaded as WPF Class Library. – Étienne Laneville Jul 14 '20 at 17:50
it is not an easy change through the project properties (alt+enter). you need to manually edit the .proj file in an editor ( say notepad / textpad) when you compare a classlibrary project and a WPF Usercontrol library projects .proj file you will find the difference in them is through the nodes in the node.
you need to add ProjectTypeGuids , WarningLevel and TargetFrameworkProfile . it is my understanding, they started to dictate a project type through the PRojectTypeGuids node! which is really cool!
create a class library project and a WPF usercontrol library project and open the .proj files in an editor to compare, you should be able to figure out what i am talking here!

- 1,609
- 3
- 16
- 34
It's easy in .Net 6, just enable UseWPF under PropertyGroup, and change TargetFramework node to 'net6.0-windows'. Like below:
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>

- 1