When I have a <Label Content="{Binding ItemCount}"/>
on my View to bind to a property on the ViewModel.
On the viewmodel I have the property defined as
public int ItemCount
{
get { RowViewModelsCollectionView.Count; }
}
I am clearly asking for count on the CollectionView
, where I am expecting to get the count of only visible items. Unfortunately I get the count of the entire rows, even the ones not showing on the view due the filter.
Update:
in Ctor:
RowViewModelsCollectionView= new ListCollectionView(rowViewModels) {Filter = Contains};
private bool Contains(object obj)
{
RowViewModel rowViewModel = obj as RowViewModel;
if (rowViewModel != null && Books.ContainsKey(rowViewModel.Book))
{
RaisePropertyChanged("ItemCount"); // Trying out to raise it without joy
return true;
}
return false;
}
How should I fix this?