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

前端 未结 9 1388
一个人的身影
一个人的身影 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条回答
  •  萌比男神i
    2020-11-29 21:17

    Write your code in window1.

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

提交回复
热议问题