using System; using System.Collections.Generic; using System.Linq; using GalaSoft.MvvmLight.CommandWpf; using HandyControl.Data; using HandyControlDemo.Data; using HandyControlDemo.Service; namespace HandyControlDemo.ViewModel { public class PaginationDemoViewModel : DemoViewModelBase { /// /// 所有数据 /// private readonly List _totalDataList; /// /// 页码 /// private int _pageIndex = 1; /// /// 页码 /// public int PageIndex { get => _pageIndex; set => Set(ref _pageIndex, value); } public PaginationDemoViewModel(DataService dataService) { _totalDataList = dataService.GetDemoDataList(100); DataList = _totalDataList.Take(10).ToList(); } /// /// 页码改变命令 /// public RelayCommand> PageUpdatedCmd => new Lazy>>(() => new RelayCommand>(PageUpdated)).Value; /// /// 页码改变 /// private void PageUpdated(FunctionEventArgs info) { DataList = _totalDataList.Skip((info.Info - 1) * 10).Take(10).ToList(); } } }