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.
MVVM solution without code-behind could also look like this:
View:
ViewModel:
public ICommand CloseWindowCommand
{
get
{
return new RelayCommand(SystemCommands.CloseWindow);
}
}
But SystemCommands is from .net-4.5 so if you rock in some older version of .net you can also use following.
public ICommand CloseWindowCommand
{
get
{
return new RelayCommand((window) => window.Close());
}
}