Cascade Remove Region

Topics: Prism v4 - WPF 4
Jan 2, 2012 at 4:44 AM

Hello
Unfortunately I have not found the answer to your question.
There are nesting, for example:
MyRegion0 <-MyView1 (MyRegion1)
MyRegion1 <-MyView2 (MyRegion2)
MyRegion2 <-MyView3 (MyRegion3)

When I delete from MyView1 in MyRegion0, and then try again to add to MyView1 in MyRegion0, then an error is displayed:

An exception occurred while trying to create region objects.
     - The most likely causing exception was: 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Practices.Prism.Regions.Behaviors.RegionCreationException: An exception occurred while creating a region with name '____Region'. The exception was: System.ArgumentException: Region with the given name is already registered: ____Region

 

I understand that when you remove MyView1 I should cascade delete all regions of the manager. I do not know how to do it!

Clearly, each View "know" which regions had, therefore, these regions can be easily removed, but how to remove the regions of View, which in this region?

Developer
Jan 2, 2012 at 3:17 PM
Edited Jan 2, 2012 at 3:19 PM

Hi,

Based on my understanding of your scenario, your problem might be related to a known issue in prism, in which when a view is removed, its child regions are not removed from the RegionManager and the views are still being referenced by the region.

This issue and a possible workaround can be found in the following work item:

I hope you find this helpful,

Agustin Adami
http://blogs.southworks.net/aadami