none of these seem to do the tri开发者_如何转开发ck:
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);
ListCollectionView
only implements the non-generic IEnumerable
interface. I suspect you want:
var source = myViewModel.MyListCollectionView.Cast<MyType>();
or (if some values won't be of MyType
, and that's okay):
var source = myViewModel.MyListCollectionView.OfType<MyType>();
var source = myViewModel.MyListCollectionView.OfType<MyType>();
The InternalList
property is of type IList
so you would be able to write a linq
query against that.
ahhhh found it. you have to use Cast<> first!
var source = myViewModel.MyListCollectionView.Cast<MyType>().Select(p=>p.MyProperty);
精彩评论