2015-03-03 67 views
0

我正在尝试过滤ICollectionView,我想通过IcollectionView的每个对象中的可观察集合的内容来过滤它。在对象集合中搜索字符串CollectionView

在collectionView中,我有对象,每个对象都有一个名为SomeObject的对象集合,我想通过Textsearch字符串出现在集合中的任何SomeObject对象中来过滤CollectionView。

我希望这是SENCE ...

我已经尝试了几个不同势的方法都无济于事和IM而卡住:(我似乎无法让我的头围绕这一个。我认为,这需要一些疯狂的LINQ ,我刚开始可以学到一些东西。

View.Filter = new Predicate<object>(o => ((BasePropertyTypeVM)o).Properties.Contains(i => ((SomeProperty)i).Value.Contains(TextSearch))); 

View.Filter = new Predicate<object>(o => ((BasePropertyTypeVM)o).Properties.Contains(new Predicate<object>(i => ((SomeProperty)i).Value.Contains(TextSearch); 

View.Filter = new Predicate<object>(o => ((BasePropertyTypeVM)o).Properties.Where(i => i.Value.Contains(TextSearch))); 

感谢,

山姆

+1

尝试,如果这个工程(我没有测试它的机会):'View.Filter = O =>((BasePropertyTypeVM)O).Properties.Any(P => p.Contains(文本搜索));' – cubrr 2015-03-03 12:29:13

回答

1

使用任何

它确定序列的任何元素是否满足条件。

View.Filter = new Predicate<object>(o => ((BasePropertyTypeVM)o).Properties.Any(i => i.Value.Contains(TextSearch)));