【发布时间】:2018-05-30 22:52:26
【问题描述】:
我有 ICollectionView
private ICollectionView _snapshotList;
public ICollectionView SnapshotList {
get { return _snapshotList; }
}
我在 ViewModel 构造函数中设置,其中this.smapshotListModel.SnapshotItems 返回 ObservableCollection
_snapshotList = CollectionViewSource.GetDefaultView(this.snapshotListModel.SnapshotItems);
_snapshotList.Filter = ErrorMsgFilter;
_snapshotList.CollectionChanged += OnCollectionChanged;
后来在 collectionChanged 事件中,我试图获取此集合中的项目数,
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
this.ItemCount = _snapshotList.Count();
}
但它的抛出错误,即没有定义 Count 方法。
【问题讨论】:
标签: c# wpf mvvm collections observablecollection