如何针对 ListCollectionView 编写 linq 查询?
这些似乎都不起作用:
var source = myViewModel.MyListCollectionView.Select(x => x as MyType);
var source = myViewModel.MyListCollectionView.Select<object, MyType>(x => x as MyType);
var source = myViewModel.MyListCollectionView.SourceCollection.Select<object, MyType>(x => x as MyType);
none of these seem to do the trick:
var source = myViewModel.MyListCollectionView.Select(x => x as MyType);
var source = myViewModel.MyListCollectionView.Select<object, MyType>(x => x as MyType);
var source = myViewModel.MyListCollectionView.SourceCollection.Select<object, MyType>(x => x as MyType);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
ListCollectionView
仅实现非泛型IEnumerable
接口。我怀疑你想要:或者(如果某些值不是
MyType
,那没关系):ListCollectionView
only implements the non-genericIEnumerable
interface. I suspect you want:or (if some values won't be of
MyType
, and that's okay):InternalList
属性的类型为IList
,因此您可以针对该属性编写linq
查询。The
InternalList
property is of typeIList
so you would be able to write alinq
query against that.啊啊啊找到了。你必须使用 Cast<>第一的!
ahhhh found it. you have to use Cast<> first!