I'm programming an application in WPF which uses the MVVM concept.
I'm trying to have no code-behind, and trying to keep my ViewModels and Views fully seperated. This means that I have to handle closing windows in xaml.
I want to execute a relaycommand, when I close the window, but only if I press "OK". If I press Cancel, the command must not be executed.
I have tried executing the relaycommand when the window on the trigger "IsClosing", but this doesn't work, because the command also is executed when "Cancel" is pressed. I know you can send the view as a parameter on relaycommand, but this means my ViewModel has knowledge of my View.
Does anyone know how to execute a relaycommand and close the window when I press "OK", without the ViewModel have any relation to the View?
Kind regards!