how to get the region name?
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 Framework开发者_JS百科Element;
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?
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
{
}
}
}
精彩评论