如何在winform应用程序中显示WPF窗口?我可以只使用新的win = Windows1 Windows1();win.show()吗?
发布于 2015-09-26 17:50:45
This article详细解释了以下答案。
using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
var wpfwindow = new WPFWindow.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();发布于 2015-09-26 03:13:13
嗯,奇怪的是,这不是anwered...Personally,我使用ElementHost来实现。
下面是一个详细的例子:Put WPF control into a Windows Forms Form
例如,我们有一个包含大量WinForm表单的旧WinForm应用程序。然而,每一个新开发的Windows都是用WPF完成的。
为了能够显示每一个新的WPF表单:
//create the winform Hoster, which contains a ElementHost on it
form_MyWPF_Hoster MyForm = new form_MyWPF_Hoster();
//Create the instance of your WPF control
form_WPFNewWindows MyWPF = new form_WPFNewWindows();
//Add the WPF control to the elementHost  (it is publicly accessible...i know, it's bad..)
MyForm.elementHost1.child = MyWPF ;    
//show the WinForm : 
MyForm.ShowDialog();https://stackoverflow.com/questions/5124778
复制相似问题