MEF: One region, multiple views to display at the same time

585 views Asked by At

I'm trying to build a modular application that contains the shell application and subsequent modules. I'd like to define a navigation area for modules to display a hyperlink button. I've called this region 'NavigationRegion' in the shell's view:

<ItemsControl Name="NavigationRegion" prism:RegionManager.RegionName="NavigationRegion" />

Inside each module's initialize method, I'm calling the navigation region's add method:

public void Initialize() {
    regionManager.Regions["NavigationRegion"].Add(new Views.Navigation());
}

The modules are all loaded in the bootstrapper using the AggregateCatalog.Catalogs.Add method:

this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Orders.OrderModule).Assembly));
this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(People.PeopleModule).Assembly));

The problem is, only one of the views shows up and it is the first assembly that was added to the catalog's view. So how do I get all the views added to the navigation region to show up? Or is there some other method I should be using to show all the views at the same time?

1

There are 1 answers

0
Josh On BEST ANSWER

The ItemsControl needs something to tell it to display multiple items:

<ItemsControl.ItemsPanel>
     <ItemsPanelTemplate>
        <toolkit:WrapPanel />
    </ItemsPanelTemplate>
</ItemsControl.ItemsPanel>