wpf - Filtered CollectionView Gives Wrong Count -


according documentation, count of filtered collectionview should count of items pass filter. given code:

list<string> testlist = new list<string>(); testlist.add("one"); testlist.add("two"); testlist.add("three"); testlist.add("1-one"); testlist.add("1-two"); testlist.add("1-three"); collectionview testview = new collectionview(testlist); int testcount1 = testview.count; testview.filter = (i) => i.tostring().startswith("1-"); int testcount2 = testview.count; 

i therefore expect testcount1 6, , testcount2 3. however, both 6. if manually iterate through collectionview , count items, 3, count returns 6 always.

i've tried calling refresh on collectionview, see if correct result, there no change. documentation wrong? there bug in collectionview? doing wrong can't see?

try

icollectionview _cvs = collectionviewsource.getdefaultview(testlist); 

instead of

collectionview testview = new collectionview(testlist);     

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -