Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Form within a Windows Forms project

I have an existing Windows Forms project.

Can I create an additional WPF/XAML Window (a full new window) within such a project?

Visual Studio does not offer that option, but I think that should be possible somehow, at least via code?

like image 238
SQL Police Avatar asked May 31 '15 07:05

SQL Police


People also ask

Can you mix WPF and Windows Forms?

Yes you can, both Windows Forms within a WPF application, and WPF controls within Windows Forms.


1 Answers

For this job you must add this references to your Win-Form projects:

  • PresentationCore
  • PresentationFramework
  • WindowsBase
  • System.Xaml

Help link

And to host WPF windows in WinForm or win32 apps you will need this line before you .Show() your Wpf Window:

System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(myWpfWindow);

See http://msdn.microsoft.com/en-us/library/aa348549.aspx

Helpful link: Mixing WPF and WinForms

like image 191
Behzad Avatar answered Oct 22 '22 19:10

Behzad