我有通过构造函数(Prism)注入的ViewModel。
public class MainPageViewModel : ViewModelBase, IIncrementalSource<Tender>
{
public async Task<IEnumerable<Tender>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken))
{
TendersRequest.Offset = pageIndex;
TendersRequest.Count = pageSize;
return await _dataService.GetTenders(TendersRequest);
}
public MainPageViewModel(IUnityContainer container, IDataService dataService)
{
...
var Tenders = new IncrementalLoadingCollection<MainPageViewModel, Tender>(10);
}
}
但是行 Tenders = new IncrementalLoadingCollection(10); 抛出 System.InvalidOperationException。
An exception of type 'System.InvalidOperationException' occurred in Microsoft.Toolkit.Uwp.dll but was not handled in user code
Additional information: TSource must have a parameterless constructor
我究竟做错了什么?如何将 IncrementalLoadingCollection 与自定义构造函数一起使用?