Adding WPF Windows and Pages to existing C# Projects

When working with WPF projects in Visual Studio, you can add WPF Windows, Pages,  User Controls and Resource Dictionaries to a project by right clicking on the project and selecting Add > Window…, Add > Page…,  Add > User Control… or Add > Resource Dictionary… menu options.

The problem I run into is that these menu options are only available if you selected one of the WPF project templates when adding the project to your solution.  How can we add WPF items to existing projects in our solutions?  The solution is similar to my previous post that describes adding workflows to existing projects.

  • Add references to PresentationCore, PresentationFramework, System.Core, System.Data, System.XML, System.Xml.Linq, and WindowsBase to your project. Close Visual Studio and open the csproj file in a text editor. Add the following project type Guids to the PropertyGroup element:

    *   <pre>&lt;ProjectTypeGuids&gt;{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;/ProjectTypeGuids&gt;</pre>
    
  • Re-open your solution in Visual Studio.  The WPF menu options should now be available for your project.