Dialog Managers

Apr 5, 2013 at 9:15 PM

I'm pretty new to Caliburn Micro and am trying to work through the learning curve. I've seen a lot of blogs, posts, etc about creating a "Dialog Manager / Loader" usually using IResult to display a Message Box (always a ViewModel / View to represent an old fashioned MessageBox).

I am probably missing the point, but it seems like all the methods do a pile of plumbing to do the exact same thing that WindowManager.ShowDialog(new MyMessageBoxViewModel()) does. In fact, a lot of the examples I've seen use WindowManager.ShowDIalog() at the end of their plumbing run. After code returns, you can examine the value of your MessageBoxViewModel's "Result" property and continue on.

I can see the advantage of having an "IResult Loader" for use in corutines, but to simply display a message box viewmodel, calling Coroutine.BeginExecute(DoShowDialog()).GetEnumerator() seems overkill.

Help me out, what am I missing here?
Apr 14, 2013 at 8:47 AM
One scenario we use a dialog manager yielding an IResult is to collect a file as input then display a progress dialog as it processes. This 2-step interaction works due to the result sequence processing, and the information we get from the file dialog can be much more complex (for example, file name/path, options to skip certain data, etc.) than just a message box.
Apr 14, 2013 at 10:38 PM
I absolutely understand the the benefits of using IResult processing in situations like you describe. Not questions it's fantastic. I'm more thinking of the "I just need to display an "OK" message box with no further processing and don't even care about the "Result" property of the dialog. Is there any good reason to not display it with the Window Manager? Is there any reason not to use the code below over making a call to my "IResult DialogLoader" through a mediator method and calling .GetEnumerator() on it which seems like a lot of extra step for ultimately doing the same thing (usually the code below is what ends up being called in the DialogLoaders I've seen)?
var viewModel = new CustustomDialogViewModel("My Caption", "My Message", CustomDilaogButtons.OK);
Apr 15, 2013 at 7:47 AM
Sounds like overkill for your scenario. If WindowManager.ShowDialog works for you in this scenario, it's probably the right choice. No need to use something just for the sake of using it. You might find it harder to refactor out later if needed, if the dialog sequence becomes more complex say, for example, if the requirements change slightly and more user input is needed beyond a simple "Ok" (e.g., a "don't show this dialog again" choice is added). This might be a factor in choosing which path to take. Also, the dialog manager is easy to represent as an injectable interface, which might be a better abstraction to rely on if you plan to do cross-platform development (e.g. WinRT + WPF).