Why Removed view still in SingleActiveRegion's filterditems of ViewCollection

Topics: Prism v4 - Silverlight 4
Oct 9, 2011 at 2:20 AM
Edited Oct 9, 2011 at 2:25 AM

Why Removed view still in SingleActiveRegion's filterditems of ViewCollection?

(1)I have two view, "loginView" and "mainView". and one SingleActiveRegion "mianRegion"

(2)loginView created by the view discovery

var vLogin = _container.Resolve<ILoginPage>(); 






(3)mainView created by the view discovery and remove loginView

 var vLogin = _regionManager.Regions["mainRegion"].GetView("loginView");
                if (vLogin != null)
                    _regionManager.Regions["mainRegion"].Remove(vLogin );

var vMain = _container.Resolve<ILoginPage>(); 


(4)"loginView" still can be find,there are two view in filteredItems.
Namespace	Name	
System	Object[] (#107,836)	[...]
System.Collections.Generic	List<object> (#107,841)	_items
Microsoft.Practices.Prism.Regions	ViewsCollection (#20,134)	filteredItems
Microsoft.Practices.Prism.Regions	SingleActiveRegion (#25,771)	views
Microsoft.Practices.Prism.Regions	IRegion[] (#25,198)	[...]
System.Collections.Generic	List<IRegion> (#25,199)	_items
Microsoft.Practices.Prism.Regions	RegionManager.RegionCollection (#25,200)	regions
Microsoft.Practices.Prism.Regions	RegionManager (#1,552)	regionCollection
Enginuity	ShellHolder (#1,416)	RegionManager.RegionManager
System.Windows.Controls	ToolTipService	_rootVisual

Oct 11, 2011 at 5:14 AM

You need to deactivate the view? ViewCollection will have all the views, but ActiveViews will just have the current active view. this again depends on what your container is for your region. Example ItemsControl supports more than one active views (i.e. AllActiveRegion), whereas a ContentControl supports only one active view at any point in time (i.e. SingleActiveRegion).