Region.Views.Count() not available

Topics: Prism v2 - Silverlight 3
Aug 14, 2009 at 8:52 PM

Currently, I cannot access the Views count in a region. Being told that IViewsCollection does not have a Count() method. I have an instance of the shell region manager in a presenter that was passed in via the constructor as IRegionManager.


I recently made two changes to the TabControlRegionAdaptor and recompiled the Composite.Presentation.dll - they were the TabItem HeaderTemplate fix (suggested here: and I also wrapped TabItem with a custom TabItem which does some stuff OnApplyTemplate. I don't see how that could suddenly make the Count() method unavailable in the region, but could it?


Just really confused as I see plenty of examples like this:

IRegion mainRegion = regionManager.Regions[regionName];

int viewsAmount = mainRegion.Views.Count();


That snippet will not compile for me....


Thanks in advance for any suggestions and apologies if I am missing something really obvious....

Aug 14, 2009 at 10:11 PM
Edited Aug 14, 2009 at 10:13 PM

Hi headbiznatch,

You are probably not using the System.Linq namespace. The count method that usually can be used in IViewCollection is just the extension method that linq provides on IEnumerable. Try adding using System.Linq;

If this does not resolve your issue, what is the compile error that you are receiving?

Hope it helps!

Matias Bonaventura

Aug 14, 2009 at 10:13 PM

You beat me to the punch! Just figured it out and yeah, I feel like a moron. Thanks....