I have a simple WPF application where I don’t have any mvvm framework like mvvmlight. Is there as way to bind a window close event to an ICommand that’s in the view model?
I tried something like
<Window.CommandBindings>
<CommandBinding Command="Close" Executed="{Binding WindowClose}" />
</Window.CommandBindings>
but obviously it doesn’t work because it’s looking for an event handler. Is there a simple way to do this?
Subscribe on event Closing and invoke WindowClose.Execute(null) from code.
Or use EventToCommand (from some MVVM toolkits).