views:

21

answers:

0

Afternoon all,

I am attempting to filter a WPF Listbox control which is bound to a collection of Entity Framework objects.

I am running into a problem which I cannot find much help on:

Firstly I am creating a BindingListCollectionView and then set its DefaultView to my collection of entity objects db.Users.

BindingListCollectionView _visituserview = (BindingListCollectionView)CollectionViewSource.GetDefaultView(db.Users);

Next i want to be able to filter the CollectionView like so:

_visituserview.CustomFilter = "FirstName <> ‘Steve’";

The problem I'm facing is that for this to work my BindingListCollectionView must have its read-only property CanCustomFilter set to True. No matter what I try I cannot get this property set to true so I get a runtime error each time.

I hope I'm not missing something really obvious! Any help is greatly appreciated!