No creation of a WPF window in a DLL project?

Antoine Jeanrichard picture Antoine Jeanrichard · Aug 26, 2010 · Viewed 30.7k times · Source

Is there a reason why Visual Studio won't let me create a WPF window in a DLL project?

I "solved" it by creating a window in an Application Project and copying it to my DLL project. I also found that I could just create a UserControl and change the base class to "Window".

But if I had to do it this way, it's maybe because I shouldn't do it...

Answer

Florian Doyon picture Florian Doyon · Aug 26, 2010

Make sure the project type is WPF User Control Library when you create your project.

If it isn't then no sweat, just edit the csproj file and make sure the <ProjectTypeGuids> element under Project/PropertyGroup contain the following GUIDs

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

Also, make sure you reference PresentationFramework and System.Xaml in your project, or you will not get any WPF in your code.