我想根据类型(类型AddPoint)过滤ObservableCollection到一个子集,并希望它按升序排序,没有重复.我的基类是ModelBase,w /子类AddPoint,Time,Repeat等...... ObservableCollection MotionSequenceCollection将以任何顺序填充这些类型,有些将是重复的.
我已经尝试了几次不同的时间,并在ICollectionView属性中显示它们,我从'拉出': 绑定集合的子集.
可观察的收藏品
private ObservableCollection<ModelBase> _motionSequenceCollection =
new ObservableCollection<ModelBase>();
public ObservableCollection<ModelBase> MotionSequenceCollection
{
get
{
return _motionSequenceCollection;
}
set
{
if (_motionSequenceCollection == value)
{
return;
}
var oldValue = _motionSequenceCollection;
_motionSequenceCollection = value;
// Update bindings, no broadcast
RaisePropertyChanged();
}
}
public ICollectionView Location
{
get
{
var location = CollectionViewSource.GetDefaultView(_motionSequenceCollection);
//DOES NOT WORK. PROBLEM: GetType() creates type of system.type() and AddPoint, which don't work. Need a cast, or something??
// found at https://stackoverflow.com/questions/9621393/bind-subset-of-collection …Run Code Online (Sandbox Code Playgroud)