Prism - how to get region name from view registered in region

Topics: Prism v4 - WPF 4
Dec 10, 2012 at 5:46 PM


Is there any way to get region name from view registered with region ?






Dec 10, 2012 at 6:59 PM


Based on my understanding what you want to do is, from inside a view, obtain the name of the region where the view was registered (for example with RegisterViewWithRegion).

As far as I know, Prism does not provide any specific functionalities to achieve this. However, I believe a possible approach could be to iterate over the collection of regions to find which ones contains the view. For example, you could do something similar to this inside the corresponding view:

foreach(var region in regionManager.Regions)
		regionName = region.Name;

Please, let us know if we have misunderstood your scenario,

Damian Cherubini

Dec 10, 2012 at 9:30 PM
Edited Dec 10, 2012 at 9:36 PM


 What about this?



works fine
Dec 11, 2012 at 1:51 PM


Based on my understanding the GetObservableRegion will return the IRegion that is hosted by the control you passed as the parameter which may not be useful if you want to retrieve the region where the passed control is registered. In which case calling the following line:

May behave similarly to calling the following method:


On the other hand, the RegionContext can be useful to share contextual information between the hosting region and the views in it. In which case, I believe this could be used to pass the name of the hosting region to its child views. However, you will have to ensure you are sharing the correct information when setting the value passed through the RegionContext property.

Please let me know if you are using a different approach to achieve this kind of scenario,


Agustin Adami