#989 – Enabling Live Filtering in a CollectionViewSource

Like sorting, filtering in a CollectionViewSource is not automatically done when you change the contents of one of the data bound items.  By default, you need to call the Refresh method of the CollectionViewSource.

In the example below, we filter on first name “Joan” and then change Joan Fontaine’s first name to “Bob”.  Notice that the list is not re-filtered–Bob remains in the list.



You can fix this by adding the FirstName property to the LiveFilteringProperties collection of the CollectionViewSource and setting IsLiveFilteringRequested to true.

        <CollectionViewSource x:Key="cvsActors" Source="{Binding ActorList}"
                <scm:SortDescription PropertyName="LastName" />

Now, when we change Joan to Bob and we’re filtering on “Joan”, Bob automatically disappears from the list.



About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

5 Responses to #989 – Enabling Live Filtering in a CollectionViewSource

  1. Guy says:

    what xmlns should be added to the heading of xaml to get the below accepted:

  2. Ed Plunkett says:

    Where in your code do you specify that it’s filtering on “Joan”?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: