WPF CollectionViewSource Multiple Views?

后端 未结 2 1417
生来不讨喜
生来不讨喜 2020-12-09 09:50

I\'ve written a Custom WPF Control with search extension, let\'s name it MyControl. The Control is a descendent of an ItemsControl class.

2条回答
  •  伪装坚强ぢ
    2020-12-09 10:43

    The problem there is that CollectionViewSource.GetDefaultView(object) will always return the same ICollectionView instance for a given source, and this is what any ItemsControl extension will use when displaying that source.

    You can get around this by creating a new instance of ICollectionView to be used by each control that you want to be able to independently filter the collection, and then explicitly binding the ItemsSource property of each control to that specific view. The type of ICollectionView needed would depend on your scenario, but ListCollectionView is generally appropriate.

提交回复
热议问题