So my first attempt did everything out of the code behind, and now I\'m trying to refactor my code to use the MVVM pattern, following the guidance of the MVVM in the box inf
My solution to close a window from view model while clicking a button is as follows:
In view model
public RelayCommand CloseWindow; Constructor() { CloseWindow = new RelayCommand(CloseWin); } public void CloseWin(object obj) { Window win = obj as Window; win.Close(); }
In View, set as follows