我使用了 ObservableCollection 类型的 object 。我尝试通过以下代码过滤
public ObservableCollectionView<Person> SampleEntries { get; set; }
private void ApplyFilter(int age)
{
SampleEntries.Filter = (entry => entry.Age > age ) ;
// converting ObservableCollection into AsQueryable
var source = this.SampleEntries.AsQueryable();
//Shows the value as Destination array was not long enough
var source1 = source.OrderByDescending(x => x.Id);
}
应用过滤器后,尝试对列进行排序,它抛出
Exception : "System.ArgumentException was unhandled by user code" Message=Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
注意:我需要知道为什么这段代码不起作用。我们已经有其他方法来解决这个问题。
更新:ObservableCollectionView
可以在MyToolkit库中找到该类。