ChildWindow

Jul 23, 2010 at 6:47 PM
I can show a ChildWindow using the handy WindowManager.ShowDialog method. What's the MVVM-friendly way to handle closing the dialog? I can put OK and Cancel methods on the viewmodel to handle their respective button clicks. But how should I then close the window? Thanks in advance.
Coordinator
Jul 23, 2010 at 6:52 PM

If you inherit your VM from screen, you can just call TryClose() Try close does the following:

1. Looks at the VM's parent. If it is not null, asks the parent to close the child.

2. If no parent, looks up the default view for the VM and attempts to close the view.

Jul 23, 2010 at 7:24 PM
Perfect! Thank you for the rapid reply as well. I love how simple Caliburn.Micro makes things. I have to stop myself over thinking it :)