Single Window Conductor with Grid Based Child Windows

Topics: Getting Started, UI Architecture
Jul 10, 2012 at 2:26 AM

I was wondering how to conduct between child windows inside the same window. For example, in ShellView, I could have a grid with one item being the ActiveContent and another grid item being a modal window. They would both have the same grid location (row & col), but the modal would be hidden or the bound property as null until I was showing something. Then I would load the viewmodel and store in the bound property and the window would show over the activeitem.

This sounds like a specialized form of conductor and I was wondering if and how this could be done.



Jul 10, 2012 at 4:17 PM
Edited Jul 10, 2012 at 4:18 PM

I had the exact same problem. We have a Shell + a MainMenu landing screen, that can either load a "normal" screen or it could be another menu , that can load a child screen.

I resorted to a hack:

I use MEF and export the Screens as Shared parts and add a Name to the Export to indicate what Menu the screen belongs on.

    [Export(typeof (IWorkspace))]
    [Export("landing", typeof (IWorkspace))]
    internal class DriverLogMenuViewModel : Screen, IWorkspace
    { ... }

The Shell loads a list of all the Screens (this would be a great place for a Lazy<Screen> implementeation). Then I use [ImportMany] with a qualifying name in a Constructor Injection for that particular menus ViewModel 

 public DriverLogMenuViewModel([ImportMany("driverslog", typeof (IWorkspace))] IEnumerable<IWorkspace> buttons)
 { ... }

The Screens implement the IWorkspace ideas frrom the Billy Holiday HelloWPF sample so there is a ShowMe() implementation and a DisplayName that gets set

In the particular Menu's ViewModel

public void  ShowVehicleInspection()
    Buttons.Single(i => ((Screen)i).DisplayName == "VehicleInspection").ShowMe();

Will activate that particular Screen

public void ShowMe()

I really don't like having to spin up all the VM's in the beginning. If anyone has a Lazy<Screen> implementation that would work seamlessly. It would be a nice contribution.



Jul 11, 2012 at 2:55 AM

Thanks Adam,

I am still trying to find a way to not spin up the VM's. Since I am using Caliburn.Micro.Autofac, I got a Func<ViewModel> in the constructor. The problem is that when I assign it to the ContentControl, it still doesnt show. Worse, the datacontext of the ContentControl is set to the parent control. I am almost tempted to use a tab control for the children, hide the tab bar (somehow), and only show the activetab when I need to show my child window.


Jul 11, 2012 at 6:39 PM

Ok. I just realized that I am experiencing a RTFM moment. Rob documented a dialog conductor on

Now to see if it can work for me.


Jul 11, 2012 at 10:19 PM

I also just found implementations for LazyScreen<> and LazyConductor<> in the CoProject series of blog posts -


Jul 12, 2012 at 4:35 AM

I will take a look at it. However, adapting Rob's Hello Screens hybrid with autofac creation functors for the viewmodels gives me exactly what I want. I have a few interfaces and classes now to make it easy to add dialogs, center screens or similar to GitHub for Windows modal windows (around 2/3 of the parent). If I can make these more general purpose, and possibly disconnect them from the ReactiveUI hooks I have, I will put them out on my GitHub page.


Jul 12, 2012 at 2:10 PM
Edited Jul 12, 2012 at 2:11 PM

Hi David,

First, I think I cut my CM baby teeth on your tutorial series, so thank you.

I also need the functionality that you and Adam are discussing here, so I will be watching for your results.  If you look at my original Post, "Shell Boostrapping Error", I tried to discuss a more fundamental issue with the same Hello Screens solution.  I actually have hundreds of child screens.  My first step was to try to organize my "Hello Screens" type solution where in the original tutorial Orders, Customers, and Settings are simply in seperate folders in a single project.  To keep my issue simple I described it as though I wanted to just move Orders and Customers and Settings from their folders within the Hello Screens project, to individual seperate projects.  When I do this, the very basic screen called Settings works OK but Orders and Customers projects do not.  Perhaps you could give me some insight on how to handle this.  A great Demo would be Hello Screens organized in seperate projects.

After my more basic issue is solved, I also have need for "cascading" menus.



Jul 25, 2012 at 9:56 PM

I found the answer myself.  Here is the solution.

The problem tuned out to be in the bootstrapper.

First you need the DLL.  Add this to the Customers ClassLibrary Compile Build Events    xcopy /Y /I "$(TargetPath)" "$(SolutionDir)$(SolutionName)\$(OutDir)"

It will put a copy of the DLL in the Bin.  Now add a reference to the Customers.DLL  in the Shell Project.

Next you need to search the bin for Exports in the bootstrapper: sonething like this:

Dim VLPAssyList = New List(Of Assembly)

Dim dir = New DirectoryInfo(".")




Protected Overrides Function SelectAssemblies() As System.Collections.Generic.IEnumerable(Of System.Reflection.Assembly)


Dim assyList = New List(Of System.Reflection.Assembly) From {System.Reflection.Assembly.GetExecutingAssembly()}(Customerss.dll").Select(Function(x) Assembly.LoadFile(x.FullName)))


Here is the part that was making me tear my hair out.   I was missing the fact that just adding the Exports to the catalog was not enough so . . .

And last you need to Not only find and add the Exports to the catalog above, but for a Master/Detail as shown in the Hello Screens Customers example you need to add this line to your Configure Sub: 

batch.AddExportedValue(Of Func(Of Customers.CustomerViewModel))(Function() container.GetExportedValue(Of Customers.CustomerViewModel)())

 Hope this helps anyone else who is new to MEF and CM get started with major sections of a solution organixed in seperate projects.