一、wpf项目中引用WindowsFormsIntegration和System.Windows.Forms

二、Form1.Designer.cs 的 partial class Form1 设置为:public partial class Form1

三、代码如下:

XXXX.Form1 Zhuwindow = new XXXX.Form1();
            Zhuwindow.TopLevel = false;
            Zhuwindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            Host1.Child = Zhuwindow;

 

主要是代码: Zhuwindow.TopLevel = false; ,即可解决 WPF加载Winform窗体时 报错:子控件不能为顶级窗体 的问题。

posted on 2016-07-12 00:53  阿水乐园  阅读(1552)  评论(0编辑  收藏  举报