<Label Content="{Binding ItemCount}"/>
ViewModel のプロパティにバインドする Viewがある場合。
ビューモデルでは、次のように定義されたプロパティがあります
public int ItemCount
{
get { RowViewModelsCollectionView.Count; }
}
CollectionView
目に見えるアイテムのみのカウントを取得することを期待している で、明らかにカウントを求めています。残念ながら、フィルターのためにビューに表示されていない行も含めて、行全体の数を取得します。
アップデート:
中:
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;
}
これを修正するにはどうすればよいですか?