How To Add Winform To WindowsFormsHost

Hothreeyn picture Hothreeyn · Jan 6, 2012 · Viewed 12.5k times · Source

My Main Project Is Under WPF, In My Solution I have:

  1. winform which name is Form1
  2. wpfForm which name is MainWindow.xaml

I want to do this job: if button clicked, I show the Form1 in MainWindow Exactly Like MDI

Answer

Hothreeyn picture Hothreeyn · Jan 9, 2012

Thanks for helping me in this case,your answers really help me but i found my aim : i just wanted to use windows form (form1) in to wpf windows (not my windows form controls ) in my form code,i just change the inheritance of form1 to Usercontrol instead of Form like this

public partial class Form1: UserControl
{
  /// my code ...
}

therefor i can use this usercontrol in my windosformshost because my form is usercontrol now(nice job) but i got another problem , my controls didn't have visual sytle , cause of that i search in msdn , i got the answer from this link visual_Problem and the answer was in enable_visual i mean , before the winformshot host my windows form(ofcource my usercontrol) i should write this code :

System.Windows.Forms.Application.EnableVisualStyles();

Thanks for your comments. Best Regards, Hothreeyn.