开发者

Connect WinForms project with WPF project

开发者 https://www.devze.com 2023-03-16 17:30 出处:网络
I need to connect a WPF project with a WinForms project. I have one project done in WinForms (\"ClassRoom\") and another project done in WPF (\"ActivityRoom\"). In the WinForms project I\'ve got a fo

I need to connect a WPF project with a WinForms project.

I have one project done in WinForms ("ClassRoom") and another project done in WPF ("ActivityRoom"). In the WinForms project I've got a form called MainForm and in WPF project I have a window called MainWindow.

I need to open the MainWindow by clicking a button i开发者_如何学JAVAn MainForm.

How can I do this?


You can just open the window the same way as from the WPF application directly:

private void button1_Click(object sender, EventArgs e)
{
    var wpfWindow = new WpfProject.MainWindow();
    wpfWindow.Show();
}

You will need to add references to the WPF assemblies to your WinForms project for this to work.

Also note that this will just open the window. It won't run any code for your App.xaml.cs, if you have any.

0

精彩评论

暂无评论...
验证码 换一张
取 消