#988 – Enabling Live Sorting in a CollectionViewSource

By default, when you’re using a CollectionViewSource to do sorting, grouping and filtering in a list-based control, the sorting/grouping/filtering behavior will only updated when you explicitly refresh the CollectionViewSource (by calling Refresh) or when you add or remove something to the collection.

You can enable live sorting in the CollectionViewSource to cause it to resort items when one or more properties on the bound objects change.  In the example below, we set the IsLiveSortingRequested property to true and specify that the Actor.LastName property is the property to live sort on.

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

Now when we make a change to the last name of one of the actors, the sorting is updated.





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

2 Responses to #988 – Enabling Live Sorting in a CollectionViewSource

  1. Pingback: Enabling Live Sorting in a CollectionViewSource | Around computing

  2. Govert says:

    If you leave out the LiveSortingProperties collection (but still set IsLiveSortingRequested to true) it will use the properties in the SortDescriptions by default.

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: