CollectionViewSource Filter not refreshed when Source is changed

前端 未结 3 1499
孤独总比滥情好
孤独总比滥情好 2020-12-30 06:55

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

3条回答
  •  一生所求
    2020-12-30 07:51

    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.

提交回复
热议问题