No creation of a WPF window in a DLL project? No creation of a WPF window in a DLL project? wpf wpf

No creation of a WPF window in a DLL project?


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.


You can try adding new WPF User Control Item and change that to Window.

Add New Item->WPF->User Control

In XAML:

Change <UserControl> tag as <Window>

In CS:

Change base class from System.Windows.Controls.UserControl to System.Windows.Window.


I do it this way:1) create "WPF Application"2) remove App.xaml3) change Project properties -> Application Output type: to Class Library (originally there is Windows Application)

Otherwise you will get errors:

"Library project file cannot specify ApplicationDefinition element"

"The project file contains a property value that is not valid"