先放置一个容器控件,并设计 好WinForm(或WPF)窗口
winform 调用 wpf
ElementHost el = new ElementHost(); el.Dock = DockStyle.Fill; this.panelStation.Controls.Add(el); ucStationMess_WPF stat = new ucStationMess_WPF(); el.Child = stat;
其中,panelStation 为winform 的窗口控件
ucStationMess_WPF 为WPF窗体
WPF调用Winform
WindowsFormsHost windowsFormsHost = new WindowsFormsHost(); SubWin.ShowStprm stprm = newSubWin.ShowStprm (); stprm.TopLevel = false; windowsFormsHost.Child = stprm;
stackPanel1.Children.Add(windowsFormsHost);
其中,stprm为winform窗体
stprm.TopLevel = false; 使winform不为顶级窗体(顶级窗体不能加载到其他窗体 )
stackPanel1 为WPF的窗口控件
时间: 2024-10-14 00:58:28