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.
精彩评论