WindowManager.ShowDialog result?

Mar 10, 2011 at 12:42 AM


In the sample Caliburn.Micro.HelloWindowManager, ShowDialog returns a result. However, in RC, ShowDialog is a void.


 public void OpenModal() {
            var result = windowManager.ShowDialog(new DialogViewModel());


How do I get the result of my Dialog?

would I just do something like

var dlg = new DialogViewModel();
windowManager.ShowDialog( dlg );
var result = dlg.Result;

Mar 10, 2011 at 1:21 AM

That's a difference between wpf and silverlight. Unfortunately, what you have done won't work because the dialog is shown "async" in Silverlight, You need to grab the result after the dialog has closed. I usually do this with coroutines and some dsl magic. Have a look at the game library sample to see some similar things. But, your code might look like this:

public IEnumerator<IResult> DoSomething(){
   var dialog = Show.Dialog<MyDialog>();
   yield return dialog;

   var result = dialog.Result;
   //do something with the result.
You can have a look at the full version of Caliburn in the ShellFramework for an example of some of these types of IResults and the Show static helper. It should all be fairly easy to port to CM if you find something there that you like.