Prism 4 RegionManager loses first region when second one is added in WPF?

Also, you could try register your region manager in the bootstrapper: RegionManager. SetRegionManager(shell, this.Container.Resolve()); See the following questions: Cannot find Region in RegionManager (using PRISM) WPF, Prism v2, Region in a modal dialog, add region in code behind EDIT I looked at the sample solution (link in comments), and found out that your view injection code gets executed before main view is created. Your module initializers get called in StartRuntime->CreatePrismBootStrapper, and DisplayRootView (which creates your shell) is called later.

Of course it can't find the region when the shell hasn't been created yet. If all you want to register your subcontrols in module initialize code, view discovery is more suitable - it doesn't require your shell to be already created. View injection is better when you need to switch views based on user input (in this case making sure that containing control had been registered is up to you).

You have several options: Use view discovery - as you did in the sample solution. Create and register your Shell instance before loading your modules. Base.DisplayRootView() should be able to find it in the container so It wouldn't create another.

One way to do, but I'm not sure if best: PrismBootstrapper.Cs: protected override DependencyObject CreateShell() { Thor.Application.Views. ShellView view = new Thor.Application.Views.ShellView(); _container. Register(Castle.MicroKernel.Registration.Component.For().

Instance(view)); // _container.Resolve(); return view; } .3. CreatePrismBootstrapper() after base. DisplayRootView?

It doesn't work (NullPointerException on ServiceLocator and I'm not sure if it would make sense since I'm not really familiar with libraries used by you except Prism... Hope this helps...

There is a MainShellView, which is the Shell of the app. Inside the MainShellView is a MainSiteView, which is a UserControl, which contains the DockPanel referenced above. That DockPanel then contains the two ContentControls.As for the RegionManager, it is registered on the MainSiteView, not the MainShellView, if that has any bearing on things.

If it's registered on the MainShellView it doesn't find any regions, registering it on the MainSiteView exhibits the described behavior. – Scott May 16 at 21:55 Are you sure you don't nest your Regions? Try adding a simple control to the DockPanel and see if it stays there after adding a region.

Maybe when the second region get's added it removes all other controls from DockPanel, as if the DockPanel was the actual region? – surfen May 16 at 22:46 Here's the heirarchy: Our MainWindow is an Actipro RibbonWindow that we're creating manually in the bootstrapper. The MainWindow's content is set to MainShellView, which is a UserControl that has two ContentControls that overlap, one for the Workspace and another for Dialogs.

The Workspace ContentControl is set to the MainSiteView at startup. MainSiteView has two ContentControls, one is the ToolBarRegion and the other is the WorkspaceRegion. I've tried registering the RM with the MainWindow, MainShellView, and MainSiteView and always get this problem.

One region works, two regions fail. – Scott May 17 at 15:52 have you tried inserting 2 regions in xaml but commenting out this _regionManager. RegionsRegionNames.WorkspaceRegion.

Add(typeof(SomeOtherView));? What is the result? Also check your constant value RegionNames.

WorkspaceRegion for copy/paste error ("ToolBarRegion"? ) – surfen May 18 at 7:57 I've triple checked the copy/paste errors, so those can be ruled out. When I comment out the _regionManager code, and leave the two ContentControls in the XAML, each with their respective RegionNames associated with them, I get a shell with two empty content controls.

So that "works," if you want to call it that. It's only when I try to actually reference the first region that it blows up. – Scott May 18 at 19:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions