如何在winform applciation中显示WPF窗口?我可以使用Windows1 win = new Windows1(); win.show()?
答案 0 :(得分:1)
这是一个详细的例子: 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();
答案 1 :(得分:1)
This article详细解释了以下答案。
using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
var wpfwindow = new WPFWindow.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();