WPF MVVM: How to close a window

后端 未结 21 1829
后悔当初
后悔当初 2020-12-04 08:19

I have a Button that closes my window when it\'s clicked:


21条回答
  •  难免孤独
    2020-12-04 08:57

    In your current window xaml.cs file, call the below code:

    var curWnd = Window.GetWindow(this); // passing current window context
    curWnd?.Close();
    

    This should do the thing.
    It worked for me, hope will do the same for you )

提交回复
热议问题