How to get the current active view in a region using PRISM?

Ehsan Zargar Ershadi picture Ehsan Zargar Ershadi · Jun 15, 2011 · Viewed 8.6k times · Source

I know that i can get all the registered views in a region with :

var vs = mRegionManager.Regions[RegionNames.MainRegionStatic].Views.ToList();

and i can see there is the following code :

mRegionManager.Regions[RegionNames.MainRegionStatic].ActiveViews

which is giving a list of Active View, but I'm having my region attached to a ContentControl which always has a single ActiveView. Am i misunderstood or is there a way to get the single active view?

Answer

Navid Rahmani picture Navid Rahmani · Jun 15, 2011

var singleView = regionManager.Regions["MyRegion"].ActiveViews.FirstOrDefault();