Showing posts with label Caliburn.Micro WindowsManager. Show all posts
Showing posts with label Caliburn.Micro WindowsManager. Show all posts

Saturday, February 12, 2011

Caliburn.Micro WindowsManager.Show_XYZ methods



While Rob Eisenberg is writing The Window Manager I might as well share my findings about it.

There are 3 Show_XYZ methods:


  • ShowDialog() - shows a modal window
  • ShowWindow() - shows a modeless window
  • ShowPopup() - shows a popup
For ShowDialog() and ShowWindow(), your view should be a Window. If your view is a UserControl behind the scene Caliburn.Micro will create a window to host it. You call the method like this:

public void ShowModal()
{
    var wm = new WindowManager();
    var vm = new ModalViewModel();
    wm.ShowDialog(vm);
}

public void ShowWindow()
{
    var wm = new WindowManager();
    var vm = new WindowViewModel();
    wm.ShowWindow(vm);
}


I found ShowPopup() a bit less intuitive to use. Your view must be a UserControl and not a Popup as you might expect.

public void ShowPopup()
{
    var wm = new WindowManager();
    var vm = new PopupViewModel();
    var settings = new Dictionary();
    settings.Add("StaysOpen", false);
    wm.ShowPopup(vm, null, settings);
}


That's it. happy coding!


UPDATE - You can find a detailed artcle on WindowManager at Caliburn Micro Part 5: The Window Manager.