WPF (MVVM): Closing a view from Viewmodel?

后端 未结 11 1541
小鲜肉
小鲜肉 2020-12-12 16:23

Anybody come across a clever way of closing a view in a viewmodel using MVVM?

Maybe there is a way of using binding to signal the view (window) to close?

I w

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 16:51

    You can make a command that attaches to the window and when executed closes the window. Then you can bind that command to a property on your view model, and execute the command when you want to close the window.

提交回复
热议问题