How do I open a second window from the first window in WPF?

前端 未结 9 1199
一个人的身影
一个人的身影 2020-11-29 20:46

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?

9条回答
  •  有刺的猬
    2020-11-29 21:10

    Assuming the second window is defined as public partial class Window2 : Window, you can do it by:

    Window2 win2 = new Window2();
    win2.Show();
    

提交回复
热议问题