In caliburn micro in the interactive mode that inherits from Screen , you can:
TryClose(true); // for OK
or
TryClose(false); // for Cancel
then you can do:
var vm = IoC.Get<MyViewModel>(); var r = WindowManager.ShowDialog(vm, null, null); if (r.HasValue && r.Value) {
your xaml dialog box 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 example of the implementation code for a dialog box:
public bool CanAcceptButton { get { return true; } } public void AcceptButton() { TryClose(true); } public bool CanCancelButton { get { return true; } } public void CancelButton() { TryClose(false); }
source share