I am using CollectionViewSource to filter the records displayed in a ListBox. The xaml follows.
var count = DataGrid.ItemsSource.OfType().Count();