Best way to host multiple view in the shell ?

Nov 10, 2010 at 2:28 AM

Hello,

I've just started with CM, so far very pleased with the way everything works together.

However, I'm wondering what's the best way to solve this (not so uncommon) situation:

I want to have a ShellView which can host multiple other views (Navigation, Menu, Statusbar and something like the Output/Error window of VS for example).

The content of the child-views is dependent on the state of the application, in some states some child-views should be invisible.

The solution I have in mind so far is to create a ShellViewModel which has a Property for every child-view and a ShellView with a ContentControl

for every child view binding to those VM-Properties. (VM can also have Properties to make the ContentControls invisible).

 

Is this the standard way to do this or is there a better way I just don't see yet ?

Coordinator
Nov 10, 2010 at 2:57 AM

It sounds like a reasonable approach. It a bit hard to tell for sure from the description. I think I'd need a little more info. Have you read the docs on Screens and Conductors. Those samples might give you some ideas as well. I've got one more sample coming that's more complex. Maybe ai can get it published this week...

Nov 10, 2010 at 5:02 PM

Thanks for the quick reply!

Yes, I read the article about screens and conductors. From my understanding the conductor is responsible for hosting the "main content" area of the shell.

But my Shell should have more than one content area.

I have similar scenarios in other parts of the application which basically boil down to the same question:

What's the best way for a View to host multiple child-views ?

Looking forward for your next example, maybe it already contains what I'm looking for.

 

Coordinator
Nov 10, 2010 at 6:49 PM

In the full version of Caliburn, we have another conductor option called: Conductor<T>.Collection.AllActive, which can be used for that purpose. If you want to use it, you should be able to grab the code from Caliburn and bring it into your project. The Screens/Conductors pieces are compatible between the two frameworks. You can find the source for that class here: http://caliburn.codeplex.com/SourceControl/changeset/view/56437#1279080 Or if you don't need something that full, you can simple host other view models as properties on the parent view model and put ContentControls in your view with the same names as those properties. That should work just fine. If those child VMs are Screens or Conductors themselves, you will need to manually activate them.

Nov 11, 2010 at 12:52 AM

Thanks, I'll give it a try.

So far I'm very pleased with the framework, very well thought through.

With the documentation seeming to get more and more complete it will hopefully allow us to discover it's full power even quicker.