public static void ActivateLastView(this IRegionManager regionManager, string regionName) { var activeViews = regionManager.Regions[regionName].ActiveViews.ToList(); if (activeViews.Count > 0) { IRolodexView existingView = activeViews.Last() as IRolodexView; if (existingView != null) { regionManager.ActivateSingleView(regionName, existingView); } } else { activeViews = regionManager.Regions[regionName].Views.ToList(); if (activeViews.Count > 0) { IRolodexView existingView = activeViews.Last() as IRolodexView; if (existingView != null) { regionManager.ActivateSingleView(regionName, existingView); } } } }
public static bool ActivateViewIfExists(this IRegionManager regionManager, string regionName, Type viewType) { bool returnValue = false; IRolodexView existingView = regionManager.GetView(regionName, viewType) as IRolodexView; if (existingView != null) { returnValue = true; regionManager.ActivateSingleView(regionName, existingView); } return(returnValue); }