In caliburn micro in your dialogviewmodel which inherits from Screen you can do:
TryClose(true); // for OK
or
TryClose(false); // for Cancel
then you could do:
var vm = IoC.Get<MyViewModel>();
var r = WindowManager.ShowDialog(vm, null, null);
if (r.HasValue && r.Value) {
// do something on OK
}
your xaml of the dialog might look like this:
<Button Content="OK" cal:Message.Attach="[Event Click] = [AcceptButton()]" />
<Button Content="Cancel" cal:Message.Attach="[Event Click] = [CancelButton()]" />
using this namespace:
xmlns:cal="http://www.caliburnproject.org"
This is a detailed code sample of the dialog viewmodel implementation:
public bool CanAcceptButton
{
get { return true; /* add logic here */ }
}
public void AcceptButton()
{
TryClose(true);
}
public bool CanCancelButton
{
get { return true; }
}
public void CancelButton()
{
TryClose(false);
}