views:

68

answers:

1

using Silverlight & Prism. i create a new scoped region inside a TabControl like so:

IRegionManager regionManager = tabControl.Add(viewRegions, UNIQUEID, true);

then from the TabControl SelectionChanged event i want to get the name of that region. so i go:

TabItem item = e.AddedItems[0] as TabItem;
FrameworkElement view = item.Content as FrameworkElement;
IRegionManager xxx = RegionManager.GetRegionManager(view);

so now i have the scoped region manager at hand = xxx!

but how do i get its name? (the "UNIQUEID" param i have assigned to it ).

HOW?

A: 

If you have the RegionManager, and the View, then you can get the region Name (but I don't know why you'd ever want to). If you loop through the regionmanger like this you can get what you want. You'll have to keep a reference around to the scoped RegionManager, but there's no way around that. (There is some extra code demonstrating other things that someone might want to do too)

    private void UnloadRegion()
    {
        foreach (IRegion region in xxx.Regions)
        {
            for (int ix = region.ActiveViews.Count() - 1; ix >= 0; ix--)
            {
               if (WhateverYourCurrentViewIs == region.ActiveViews.Last())
               {
                    string RegionName = region.Name;
                    //there is the name
               {
            }
        }
    }
thepaulpage
sorry but this does not work for me.when i add a scoped region inside some other region (a TabControl in my case) the newly added scoped region is not inside _RegionManager.Regions.
shemesh
I know that. I'm saying that you'll have to go through the scoped region just the same as you would the _RegionManager
thepaulpage
i don't get what u mean. how do i know the scoped region name?
shemesh