过滤的CollectionView提供错误的计数
根据文档,过滤的CollectionView的Count应该只是通过过滤器的项目数。鉴于此代码:
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("");
int testCount2 = testView.Count;
因此我希望testCount1为6,testCount2为3.但是,两者都是6.如果我手动迭代CollectionView并计算项目,我会得到3,但Count总是返回6。
我试过在CollectionView上调用Refresh,只是为了看看是否会纠正结果,但没有变化。文档错了吗? CollectionView中有错误吗?我做错了什么,我看不到?
没有找到相关结果
已邀请:
3 个回复
素汞读
代替
徘廷
这似乎适用于CollectionView,所以这肯定指向一个错误:
寇剩