Add WPF Window in a Winforms Project in VS 2010

It is possible to do this, I've had to do use this technique a few times without any problems:

How to programmatically create a WPF window in a WinForm application


Apparently you cannot directly, but what you can do is add a new user control and then modify the code to make it a Window. Simply create a new WPF project, add a window and see what you need to change to turn your user control into a window.


In my opinion the "cleanest" option is using this scheme:

  1. Create a WPF project (add any WPF windows you need). Lets call it "WPFProject"
  2. In the same solution create a WinForms project (add any Forms you need). Lets call it "MainProject".
  3. In MainProject add references to:

    • WPFProject
    • PresentationCore
    • PresentationFramework

Thats all, now you can open your WPF windows from your MainProject (eg. by pressing a button):

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim mywpfform = New WPFProject.MainWindow //MainWindow is the default name of your first WPF window. Obviously you can open any other
        mywpfform .Show()
End Sub