Is there a way to un-register a region from the RegionManager?
With
RegionManager.SetRegionName(myRegion, regionName);
RegionManager.SetRegionManager(myRegion, myRegionManager);
I do register a region at the RegionManager.
But what, if I need to remove that registration (in order to register the exact same region again)?
===================
This is my situation:
I have an instance myView that registers a UI control (a DependencyObject) myRegion as a region by using:
RegionManager.SetRegionName(myRegion, regionName);
RegionManager.SetRegionManager(myRegion, myRegionManager);
When myView is instantiated, also the local region manager object myRegionManager is instantiated.
Then I need to again create the instance myView, which again makes this registration.
Hence, the new instance myView also instantiates a new local region manager myRegionManager, which of course has no regions associated with.
Then, the call to RegionManager.SetRegionName(...) and RegionManager.SetRegionManager(...) succeedes, but if I then try to access the local region manager myRegionManager by using
IRegion region = myRegionManager.Regions[regionName];
I am getting an RegionUpdateException!
If I place
string name = RegionManager.GetRegionName(myRegion);
IRegionManager regionManager = RegionManager.GetRegionManager(myRegion);
in front of the registration, both fields are empty by the first instantiation of myView, but they do have values during the second instantiation of myView.
But since both the myRegion and the myRegionManager also get newly instantiated together with myView I expect the name and region manager also to be empty before calling the second registration.
myViewthat sets a region name on amyRegionand then you create a newmyViewand a newmyRegionand the newmyRegionstill has the region name of the old one, correct? Are you sure you're really looking at the new one? if you recreate themyViewfirst, it might use the oldmyRegionor the oldmyRegionManageror both... - Haukinger