WPF, Prism v2, Region in a modal dialog, add region in code behind?

The problem is that regions search up the visual tree for the RegionManager attached property, and then register themselves with that manager. In the main window that's fine, but in a child window this doesn't happen.

The problem is that regions search up the visual tree for the RegionManager attached property, and then register themselves with that manager. In the main window that's fine, but in a child window this doesn't happen. In the Bootstrapper, after the shell is created, the following code is performed.RegionManager.

SetRegionManager(shell, this.Container.Resolve()); RegionManager.UpdateRegions(); To get the region manager to work with your child window do the same thing right after you've created the window. EDIT To set the region name of a control, you also set the attached property of the RegionManager, like so... RegionManager. SetRegionName(control, "MyRegion"); However you can do this in xaml aswell.

The reason why you're regions in a separate window don't work is because the RegionManager needs to be set on the base window, like I showed above.

This code doesn't seem to help me any, my regionmanager doesn't seem to have a fucntion called SetRegionManager(), or UpdateRegions(). Is there no way of creating a new region in code behind? – Shaboboo Jun 22 '09 at 13:37 These are static calls on the RegionManager class, not instance methods.

Also I'll update my answer to show how to create regions in code. – Cameron MacFarland Jun 22 '09 at 13:58 Thanks for pointing out the RegionManager's static method to set the region name. That was exactly what I was looking for!

– Steven Magana-Zook Mar 21 at 18:05.

It is actually quite simple. In your popup xaml add a regionname as you do in the shell. Then in the popups constructor, add the following call: public Popup(IRegionManager regionManager) { InitializeComponent(); RegionManager.

SetRegionManager(this,regionManager); } This works for me in Prism v.1 - shouldn't be too much different in later versions.

I found something thats almost working. I'm sure if I could bind the region's active view to the contentContol's content property then it would work, but I haven't managed that yet. IRegionManager MyRegionManager = container.Resolve(); SingleActiveRegion newRegion = new SingleActiveRegion(); MyRegionManager.Regions.

Add("WizardSteps", newRegion); //Binding Binding myBinding = new Binding("ActiveViews"); myBinding. Source = newRegion; view.stepControl. SetBinding(ContentControl.

ContentProperty, myBinding).

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