How to cancel window closing in MVVM WPF application
How can I cancel exiting from particular form after Cancel button (or X at the top right corner, or Esc) was clicked? WPF: <Window ... x:Class="MyApp.MyView" ... /> <Button Content="Cancel" Command="{Binding CancelCommand}" IsCancel="True"/> </Window> ViewModel: public class MyViewModel : Screen { private CancelCommand cancelCommand; public CancelCommand CancelCommand { get { return cancelCommand; } } public MyViewModel() { cancelCommand = new CancelCommand(this); } } public class CancelCommand : ICommand { public CancelCommand(MyViewModel viewModel) { this.viewModel = viewModel; } public