Windows Phone 7

wp7 Collectionviewsource filtering

Having read a recent question on the App Hub Forums I decided to update my previous post on CollectionViewSource to enable filtering.

So, I added a text box to enter the filter string,




And the following code to implement the filtering…

     private void FilterBoxTextChanged(object sender, TextChangedEventArgs e)
Source.View.Filter = o =>
var item = o as Item;
if (item != null)
return item.Text.Contains(filterBox.Text);
return false;

and we get filtered results…



Here’s the updated project!436&parid=4F1B7368284539E5!123


6 thoughts on “wp7 Collectionviewsource filtering

    1. I was having this problem as well using this method in a ViewModel rather than in the page and found that the main problem was due to newing and setting .Source in the VM ctor. I moved these few lines of code to the get accessor of the public CollectionViewSource property and it eliminated the exception.

      However, filtering is not working still; the items are enumerated and set to a bool value of true is returned for the correct items in the ObservableCollection, but they seem to be ignored, as the list is not filtered. Even calling CollectionViewSource.View.Refresh() makes no difference. :/ Any suggestions?

  1. I have one question.
    I use the methode which is a basic app that you can select bystarting a new project. It is named DataBount or …Bound. But i have no idea how i can use your solution for my app.
    Please help me. I’m sure that is a long time when you write this but i need your help.

Leave a Reply

Your email address will not be published. Required fields are marked *