I'm new to WPF and I tried to implement a demo application with RelayCommand.
My question is this:
If i want to execute a command which has to ask the user if he's sure he wants to execute it first - what's the best way to do it? I need an "are you sure?" messagebox to pop. However, the command is executed on the viewmodel, and of course I don't want to mess with GUI there.
Thanks
I just ran into this myself. I'm using MVVM Light, and I used the Messenger to accomplish this.
I had my ViewModel send a
GetConfirmationMessage
, which I had registered in the code-behind. Within the handler forGetConfirmationMessage
, I popped up the dialog box and got the reuslts. If the user clicked on OK, I then sent aConfirmationReceived
message, which was handled by the ViewModel to do the appropriate updates.