简体   繁体   English

如何将ItemsSource绑定到多个集合?

[英]How to bind ItemsSource to multiple collections?

I have a few sources that expose an ObservableCollection<MyData> property. 我有几个公开ObservableCollection<MyData>属性的源。 Now I want to bind ListBox.ItemsSource to all of them and support CollectionChanged notifications, sorting and filtering. 现在我想将ListBox.ItemsSource绑定到所有这些并支持CollectionChanged通知,排序和过滤。 How to do that? 怎么做? CompositeCollection doesn't support filtering. CompositeCollection不支持过滤。

You can use CompositeCollection and CollectionViewSource together.. use CompositeCollection to combine all collections and later create a collection view source from that CompositeCollection. 您可以一起使用CompositeCollection和CollectionViewSource。使用CompositeCollection组合所有集合,然后从该CompositeCollection创建集合视图源。 You can use filter properties in CollectionViewSource 您可以在CollectionViewSource中使用过滤器属性

Look Here for Sample 在这里寻找样品

How to handle a CompositeCollection with CollectionView features? 如何使用CollectionView功能处理CompositeCollection?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM