|
I am trying to host a custom WPF controlin a C# WinForms project.
I have found several walkthroughs for this online:
1) http://msdn.microsoft.com/en-us/library/ms745781.aspx 2) http://www.codegod.de/webappcodegod/embedding-wpf-usercontrol-in-winforms-AID422.aspx 3) http://blog.paranoidferret.com/index.php/2008/06/24/wpf-tutorial-using-wpf-in-winforms/
The MSDN tutorial is slightly different in that it suggests creating a separate project to contain the custom control, whereas the other walkthroughs just add the WPF control to the current project.
I have tried both methods, and I get the same result. That is, when I add the ElementHost object to my WinForm, it does not detect any valid hostable content.
I have tried manually forcing it to host the content using the sample code provided in (1).
However, this results in a compile error at:
// Assign the WPF UserControl to the ElementHost control's // Child property. host.Child = uc; //error CS0029: Cannot implicitly convert type 'WindowsFormsControlLibrary1.UserControl1' to 'System.Windows.UIElement'
Please let me know what could be the problem and why these walkthroughs are not working for me
|