how to create new region at runtime

Topics: Prism v1, Prism v2 - Silverlight 2, Prism v2 - Silverlight 3, Prism v2 - WPF 3.5
Oct 16, 2009 at 5:09 PM


I want to add region dynamically..that means.. there are any number of regions may be 2 or3 or 4.. So I should be able to create those regions dynamically.. also I want to know that how to set locations of those regions on shell...

Please let me know how to achieve it.




Oct 16, 2009 at 10:37 PM

Hi Parthiv,

To create a region dynamically and place it at a particular location there are two main things to get done:

  1. Add the control that will host the region (ItemsControl, ContentControl, etc) to the VisualTree. This is when you will selected the location of the element and its layout. Prism does not provide any particular support for this, so you might find a better answer on how to get this done in the WPF forums.
  2. Create a Region to be hosted in the control. To make that control a region you can use code the RegionManager’s SetRegionName method:
    RegionManager.SetRegionName(yourControl, "YourNewRegion");

Please let me know if this helps.

Damian Schenkelman

Feb 8, 2010 at 12:43 PM

How to create regions out of docking panels after loading docking layout from xml?

I am using telerik docking manager and Prism for building composite WPF application