【发布时间】:2017-06-01 07:09:07
【问题描述】:
我有一个问题。我有一个非常简单的分页机制,结合了 WPF 按钮和数据网格,它看起来像:
public CatalogViewModel()
{
this._catalog = new CatalogContexct();
DbQuery<Candidate> candidatesValues = this._catalog.Candidates.Include("commendation");
this._totalItems = candidatesValues.Count();
this._candidates = candidatesValues.ToArray()
.OrderBy(c => c.Firstname).Skip(this.Start).Take(this._itemCount).ToList();
this._filters = new Dictionary<string, Predicate<Candidate>>();
var candidates = new ListCollectionView(this._candidates);
this.CandidateView = CollectionViewSource.GetDefaultView(candidates);
this.FirstameCommand = new RelayCommand(FilterFirstname, param => this._canExecute);
this.LastnameCommand = new RelayCommand(FilterLastname, param =>
CandidateView.Filter = FilterCandidates;
//should be something else to limit view to page so filter can be done on whole source not only part of it like above
}
但正如我所描述的,我需要在分页之前过滤值或对 this.CandidateView = CollectionViewSource.GetDefaultView(candidates); 的过滤值进行分页。
有可能吗?
如果我手动过滤集合并将该值传递给查看,我会很顺利,但我想知道是否有比手动操作数据更简单的方法。
【问题讨论】:
标签: c# wpf pagination