views:

257

answers:

2

Is there a way to host/display a full WinForms form (not just a single control) within some sort of container or wrapper type control within a WPF form? I’m looking for something similar in concept to a virtual include from php or iframe in html. Possibly by compiling it into an OCX or DLL.

+3  A: 

To my knowledge you can't host an actual WinForms Form in WPF.

However a good alternative is to create a normal UserControl in WinForms (as a Windows Forms Control Library project) that contains all required functionality and child controls.

Then in your WPF project, reference the WindowsFormsIntegration.dll (should be in the .NET tab of Add References).

Then also reference the assembly containing the WinForms UserControl and finally add a WindowsFormsHost container to the XAML.

For more information see this useful tutorial by Sacha Barber.

Ash
+1  A: 

There is an article on CodeProject that shows how to host a exe as a control on the WinForms (It's an application that uses Tab pages, drag a Winform.exe onto it, it creates a tabpage with that window in it), derived from this article here. I know you asked for specifically WPF, but perhaps that might lead you in the right direction?

Hope this helps, Best regards, Tom.

tommieb75
Didn't end up going with this but it's an awesome tool. Thanks for the link.
jasonk