Get filtered items from a CollectionView
The GetEnumerator
method takes the filter into account, so you can just foreach
over the view:
ICollectionView view = ...
view.Filter = ...
foreach(Foo o in view)
{
...
}
(assuming the objects in the original collection are of type Foo
).
You can also use the Cast
extension method:
var filteredItems = view.Cast<Foo>();