Is View Removal Automatically?

Topics: Prism v2 - WPF 4
Aug 30, 2010 at 8:00 PM

I placed a collection of Views in a TabControl. Each content of the tab item has a region name associated to a View. If I remove/release a tab item from the TabControl, does the associated View (and ViewModel) released automatically? If not, what should I do? Do I have to remove the View from the RegionManager?

Aug 30, 2010 at 9:35 PM
Edited Aug 31, 2010 at 2:12 PM


In general if you need to remove a view from its region in Prism, you can programmatically remove it by using the Remove method of the region. So, the code could look as it is shown below:


Regarding to your question. All views (and their VMs) associated to a tab will be removed if you remove that control. Given that when the garbage collection occurs it should dispose all of them, unless you have more references from other components. But take into account that it is not possible to predict when the collection will occur.

For more information on this topic, you could take a look at the following links:

 Please let me know if this helps.

Fernando Antivero