I need a way to get the regions I defined inside one of my views. For example:
<UserControl ...
mvvm:ViewModelLocator.AutoWireViewModel="True"
d:DataContext="{d:DesignInstance errorBars:ErrorBarViewModel, IsDesignTimeCreatable=True}"/>
<ContentControl mvvm:RegionManager.RegionName="{x:Static regions:SidebarRegions.ErrorSidebarContentRegion}" />
Inside my ViewModel, I dynamically set the view to the region.
_navigationService.Navigate<AnySubView>(SidebarRegions.ErrorSidebarContentRegion);
Now I need to remove the region from the RegionsManager. Thats quiet easy, but I need a way to remove it recursivly. Thats because the ErrorBarViewModel does not know if the View it navigated to also defines a Region. If it does, I will get an error when removing the View and adding a new instance if it again, because the regions are already defined.
My thought was iterating through the DependencyProperties or AttachedProperties and find out, which regions the child has defined, but it doesn't seem like this could work.
Does anyone have an idea how to get the regions a View has defined?