如何在WPF中从第一个窗口打开第二个窗口? [英] How do I open a second window from the first window in WPF?

查看:876
本文介绍了如何在WPF中从第一个窗口打开第二个窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WPF的新手。我有两个窗口,例如window1和window2。我在window1中有一个按钮。如果单击该按钮,则必须打开window2。我该怎么办?

I am new to WPF. I have two windows, such as window1 and window2. I have one button in window1. If I click that button, the window2 has to open. What should I do for that?

这是我尝试的代码:

window2.show();


推荐答案

window1中编写代码

private void Button_Click(object sender, RoutedEventArgs e)
{
    window2 win2 = new window2();
    win2.Show();
}

这篇关于如何在WPF中从第一个窗口打开第二个窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆