I think everyone else that uses an IDialogService or actually creates their own dialogs is over engineering the problem. I really like the simplistic approach of using Funcs. Here is an example. First add this to your ViewModel:
public abstract class ViewModelBase : INotifyPropertyChanged
{
/** Other ViewModel Code *//
public Func<string, string, bool> OkCancelDialog { get; set; }
}
Then when you instantiate your derived class of your ViewModel, you just attach the following code: (I typically do this in the startup like Program.cs)
var myVM = new SomeSuperViewModel();
myVM.OkCancelDialog = (msg, caption) => MessageBox.Show(msg, caption, MessageBoxButton.OkCancel) == MessageBoxResult.OK;
In your actual ViewModel code, all you have to do is call:
if (OkCancelDialog("Some crazy message.", "Caption"))
//do something if true
else
//else do something if false
In your unit tests you can do this:
var myVMToTest = new SomeSuperViewModel();
myVMToTest.OkCancelDialog = (msg, caption) => true; //could be false too if you need to test that functionality.
I prefer this approach, as it's simple and easy to test. What do other's think?