日期:2014-05-17  浏览次数:21074 次

WPF项目如何调用winform项目中的自定义控件
一个WPF项目、一个Winform下的写的usercontrol,想在WPF项目中调用此usercontrol,请问如何引用并且添加到WPF窗体上?

------解决方案--------------------
have a try,http://hi.baidu.com/stuoopluwqbbeod/item/32ec38403da42ee2bcf45167
------解决方案--------------------
Geomam.UserControl1 xx = new Geomam.UserControl1();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();     
            host.Child = xx;
            this.MStackPanel.Children.Add(host);
------解决方案--------------------
引用:
Geomam.UserControl1 xx = new Geomam.UserControl1();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();     
host.Child = xx;
this.MStackPanel.Children.Add(host);

自己可以写一个加载winfrom的用户控件
------解决方案--------------------




引用:
Quote: 引用:

Geomam.UserControl1 xx = new Geomam.UserControl1();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();     
            host.Child = xx;
            this.MStackPanel.Children.Add(host);


就这些么? 不需要引用什么之类的么





1.引用 WindowsFormsIntegration.dll
 
2.MStackPanel是Grid的Name------------<Grid Name="MStackPanel" />
3.Geomam.UserControl1 xx = new Geomam.UserControl1();这里你用你自己的控件