/// <summary> /// Perform the action to load data from data source. /// </summary> /// <returns></returns> protected async Task LoadData() { try { IsLoading = true; await OnDataLoading.InvokeAsync(new GridViewPaginationEventArgs(CurrentPage, PageSize)); } finally { IsLoading = false; await InvokeAsync(NotifyStateChanged); } }
/// <summary> /// 加载 <see cref="DataSourceProvider"/> 绑定方法的数据。 /// </summary> public async Task LoadData() { ShowLoading(); var dataSource = await Task.Run(() => DataSourceProvider()); if (!(dataSource is IEnumerable data)) { throw new InvalidOperationException($"{nameof(DataSourceProvider)} 返回的对象不是 {nameof(IEnumerable)} 的实例"); } await OnDataLoading.InvokeAsync(null); Data = data.Cast <object>().ToList(); await OnDataLoaded.InvokeAsync(Data); HideLoading(); InitializeRowCss(); }