4
votes

I've be struggling for a while trying to make it work. Basically I have a Silverlight application using MVVM/PRISM/Unity combination.

My shell consists by two Regions RootContent and RootMenu. My RegionManager.Regions are able to see those two regions just fine, and the application runs correctly.

The problem starts when one of my Views inside the RootContent opens a ChildWindow, it contains more two Regions, as follows:

<ContentControl Region:RegionManager.RegionName="WOFSCustomerLookup" />
<ContentControl Region:RegionManager.RegionName="WOFSCustomerView"  />

The ViewModel of this View that has this XAML above, even inheriting and properly resolved, the IRegionManager.Regions collection do not contains those two new Regions above, just the RootContent and RootMenu.

More Information

This is How my ChildWindow is called (it calls the "View"):

ChildWindow editor = this.container.Resolve<WorkOrderFieldServiceEditor>();
editor.show();

And this is the Constructor of my ViewModel:

public WorkOrderFieldServiceViewModel(IUnityContainer container, IRegionManager regionManager)
{
    this.container = container;
    this.regionManager = regionManager;

    // Still have just the two Root regions:
    // this.regionManager.Regions[]
}

Did I miss anything?

1
I found an interesting article that seems to tackle this situation, but I didn't get success YET, but I found useful to share, since it's very close to my problem: Ko-Lin Chang: Region Manager - Good or Evil?Dorival

1 Answers

1
votes

Pretty sure the problem is because you are not showing the WorkOrderFieldServiceEditor view through Prism but are just getting an instance of it through the container and then calling Show method directly on it. So, Prism is not really involved. When the main Shell is created through the bootstrapper, the regions defined in the View are then created in the region manager. So, you will need to look at how you Navigate to a popup window using Prism and not call the Show method directly.

Checkout the RegionPopupBehaviors.cs file in the StockTrader reference application.

http://msdn.microsoft.com/en-us/library/ff921074(v=PandP.40).aspx