Multiple regions in Shell

Oct 5, 2010 at 1:47 PM

 

Our application requires something like RegionManager in Prism:

1. few simultaneously visible regions with modules/views/screens loaded into

2. navigation in these regions.

3. Messages between regions/modules

I understood how to implement navigation with IScreen and Conductor. But conductor contains only one ActiveItem. Did I miss something?

Coordinator
Oct 5, 2010 at 3:11 PM

1. few simultaneously visible regions with modules/views/screens loaded into

In your ShellViewModel create several public properties, each representing one of your regions. In your ShellView, create ContentControls, one for each of the properties in your ShellViewModel. Name these ContentControls the same as the properties.

2. navigation in these regions.

Each of the properties representing a region can itself be a Conductor. This allows it to have independent navigation of the other regions. Make sure that in your ShellViewModel you cast each of these conductors to IActivate and call the Activate method. Otherwise the navigation within each region will not happen. (As an alternative, you can grab the code from the full version of Caliburn for Conductor.WithCollection.AllActive, and use this as the base for your ShellViewModel. This would allow you to open the child conductors and automatically make sure they are all enabled without having to do it manually. The conductor classes from the two frameworks are fully compatible. CM just doesn't have the AllActive version for size reasons.)

3. Messages between regions/modules

Use the EventAggregator.

 

This is really general guidance without knowing the specifics of your application. There are several ways to do this with CM.

Oct 8, 2010 at 8:13 PM
EisenbergEffect wrote:
 
3. Messages between regions/modules

Use the EventAggregator.

1. Where can I find tutorial/samples/etc. on using EventAggregator ?  ( I noticed the place holder for it in documentation section, but no link yet)

2. I'd also ask the same question in relation to implementing navigation with IScreen and Conductor?

 

Thanks!

Coordinator
Oct 8, 2010 at 9:30 PM

Check back in about 30 minutes for the first (of at least 3) parts on Screens and Conductors. It will probably be a few weeks before I get around to documenting the EventAggregator. In brief: Create classes for the different events you want to publish. Call publish on the aggregator to send them. Implement IHandle<T> on any class you want to receive the event, where T is the type of message it is interested in. Call the Subscribe method on the aggregator, passing in the class the implements IHandle<T>. That's it.

Coordinator
Oct 9, 2010 at 12:42 AM

The first part of the article on Screens and Conductors is now in the docs section.

Oct 9, 2010 at 1:03 AM
EisenbergEffect wrote:

The first part of the article on Screens and Conductors is now in the docs section.

Awesome!  Thanks.