PagedSource Class
The paged source. This source is obsolete. Use the PagedAsyncSource instead.
Namespace: DevExpress.Xpf.Data
Assembly: DevExpress.Xpf.Core.v24.1.dll
NuGet Package: DevExpress.Wpf.Core
#Declaration
public sealed class PagedSource :
PagedSourceBase
#Remarks
Refer to the Virtual Sources topic to learn more.
Important
The Paged
#Workflow
The PagedSource raises events consecutively in the UI Thread and processes data in a single separate Working Thread.
- The PagedSource creates a single separate Working Thread to process data.
- The PagedSource raises the PagedSource.CreateSource event. Handle this event to create an object used to request data (e.g., DbContext for EF, UnitOfWork for XPO).
- (Optional step) The PagedSource raises the PagedSource.GetTotalSummaries event. Handle this event and process summaries if you want to show them in the GridControl.
- The PagedSource raises raises the PagedSource.FetchPage event to get the first portion of data.
- When end users navigate to the next page, The PagedSource raises the PagedSource.FetchPage event to get the next portion of data.
- (Optional step) When end users apply a filter, The PagedSource raises the PagedSource.GetUniqueValues event to get unique values and show them in a drop-down filter.
Note
Only values of the Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, Date
For other types, the UI Thread creates thread-safe proxy objects. You can allow access to these values in the following ways:
- Specify the Virtual
Source , orBase. Custom Properties - Set the Paged
Source. property to true.Are Source Rows Thread Safe
#Tips
In addition to the PagedSource.FetchPage event, you should handle the PagedSource.CreateSource and PagedSource.DisposeSource) events:
source.CreateSource += (o, e) => { e.Source = new IssuesContext(); }; source.DisposeSource += (o, e) => { var issuesContext = (IssuesContext)e.Source; issuesContext.Dispose(); };
Get the IssuesContext before you obtain rows:
static FetchRowsResult FetchRows(FetchRowsEventArgs e) { // ... var issuesContext = (IssuesContext)e.Source; var issues = issuesContext.GetIssues( page: e.Skip / pageSize, pageSize: pageSize, sortOrder: sortOrder, filter: filter); // ... } static object[] GetTotalSummaries(GetSummariesEventArgs e) { // ... var issuesContext = (IssuesContext)e.Source; var summaryValues = issuesContext.GetSummaries(filter); // ... }
In the PagedSource.FetchPage handler, return a list of objects separately and specify the FetchPageEventArgs.HasMoreRows property:
source.FetchRows += (o, e) => { var fetchRowsResult = FetchRows(e); e.Result = fetchRowsResult.Rows; e.HasMoreRows = fetchRowsResult.HasMoreRows; };
You can specify the PagedSourceBase.PageSize property to set the maximum number of rows that can be displayed on a page.
- You can set the PagedSourceBase.PageNavigationMode property to Arbitrary to allow navigating to any page.
To show a total page count:
- Set the PagedSourceBase.PageNavigationMode property to ArbitraryWithTotalPageCount.
- Handle the PagedSource.GetTotalSummaries event to calculate the Count value.