Crossbow “Windows Forms and WPF Interop”
Well, yes it’s real you can add WPF controls and XAML forms to your .NET 2.0 Windows forms application ,
First of all add references to the WPF namespaces (PresentationCore, PresentationFramework, UIAutomationProvider, UIAutomationTypes, and WindowsBase).
The second step is creating an instance of the ElementHost control and the control you wish to add to your form
and then add that control to the ElementHost control. Then add the ElementHost control to your Forms control collection.
In addition, you will need to modify the project file because the Windows Application does not know what to do with the XAML file. You will need to open the project file (.csproj, etc.) in an editor like Notepad and then scroll to the bottom. You will see the following line:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
You will need to copy this line and paste it just below the above line and then change "CSharp" to "WinFX" so that the two lines look like:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFx.targets" />
Now save this file and reload the project using VS and run the application.
A sample code for the code you will be adding to your windows form that will host the WPF control
//add to your Windows form
ElementHost host = new ElementHost();
WPFUsercontrol uc1 = new WPFUsercontrol ();
host.Controls.Add(uc1);
host.Dock = DockStyle.Fill;
this.panel1.Controls.Add(host);
Enjoy :D