views:

1925

answers:

1

Hi,

I have a WPF ListView bound to a CollectionViewSource. The source of that is bound to a property, which can change if the user selects an option.

When the list view source is updated due to a property changed event, everything updates correctly, but the view is not refreshed to take into account any changes in the CollectionViewSource filter.

If I attach a handler to the Changed event that the Source property is bound to I can refresh the view, but this is still the old view, as the binding has not updated the list yet.

Is there a decent way to make the view refresh and re-evaluate the filters when the source changes?

Cheers

+1  A: 

Are you changing the actual collection instance assigned to the CollectionViewSource.Source, or are you just firing PropertyChanged on the property that it's bound to?

If the Source property is set, the filter should be recalled for every item in the new source collection, so I'm thinking something else is happening. Have you tried setting Source manually instead of using a binding and seeing if you still get your behavior?

Edit:

Are you using CollectionViewSource.View.Filter property, or the CollectionViewSource.Filter event? The CollectionView will get blown away when you set a new Source, so if you had a Filter set on the CollectionView it won't be there anymore.

Robert Macnee
Yes, I am changing the collection, and the items in the list view are updated reflecting the new collection. However filter is not re-evaluated. Doing it manually didn't help: ((CollectionViewSource)this.Resources["logEntryViewSource"]).Source = _application.CurrentLog.Entries.ObservableCollection
Steve