How to Bind to window's close button the X-button

后端 未结 4 1853
长情又很酷
长情又很酷 2020-12-20 22:55

How I can bind one of my buttons on control to X Button that closes the window ? I just want to create cancel button that just closes the window. I am using MVVM in my code.

4条回答
  •  一向
    一向 (楼主)
    2020-12-20 23:43

    You can just call the Close() method, which will close the window.

    private void MyButton_Click(object s, RoutedEventArgs e)
    {
        Close();
    }
    

提交回复
热议问题