Back to Devexpress

PagedAsyncSource Class

wpf-devexpress-dot-xpf-dot-data-304da07b.md

latest6.8 KB
Original Source

PagedAsyncSource Class

A virtual source component that allows you to bind the GridControl to a data source and display data in pages.

Namespace : DevExpress.Xpf.Data

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public sealed class PagedAsyncSource :
    PagedSourceBase
vb
Public NotInheritable Class PagedAsyncSource
    Inherits PagedSourceBase

Remarks

Run Demo: Paged Source

View Example: How to Bind to PagedAsyncSource

Read Tutorial: How to Use Virtual Sources Read Tutorial: How to Bind to a Custom Service with Restrictions

Workflow

The PagedAsyncSource raises events in the UI Thread and uses tasks to process data in parallel Working Threads. You should provide tasks to these events to obtain summaries, rows, etc. Then the UI Thread gets data you fetched.

  1. (Optional step) The PagedAsyncSource raises the PagedAsyncSource.GetTotalSummaries event. Handle this event and process summaries if you want to show them in the GridControl.
  2. The PagedAsyncSource raises the PagedAsyncSource.FetchPage event to get the first portion of data.
  3. When end users navigate to the next page, the PagedAsyncSource raises the PagedAsyncSource.FetchPage event to get the next portion of data.
  4. (Optional step) When end users apply a filter, the PagedAsyncSource raises the PagedAsyncSource.GetUniqueValues event to get unique values and show them in a drop-down filter.

You can maintain a clean MVVM pattern and specify operations above in a ViewModel. To do this, create a command and bind it to the corresponding property:

EventPropertyDescription
GetTotalSummariesGetTotalSummariesCommandGets or sets a command that allows you to get total summaries.
FetchPageFetchPageCommandGets or sets a command that allows you to fetch page rows.
GetUniqueValuesGetUniqueValuesCommandGets or sets a command that allows you to get unique values.

Tips

The following code snippets (auto-collected from DevExpress Examples) contain references to the PagedAsyncSource class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-bind-wpf-grid-to-data/CS/ViewModel/EFCore/PagedAsyncSource/MainWindow.xaml#L17

xml
<dxg:GridControl.ItemsSource>
    <dx:PagedAsyncSource ElementType="local_issues:Issue" KeyProperty="Id"
                         PageNavigationMode="ArbitraryWithTotalPageCount" FetchPageCommand="{Binding FetchPageCommand}"

wpf-data-grid-implement-crud-operations/CS/ViewModel/EFCore/PagedAsyncSource/MainWindow.xaml#L29

xml
<dxg:GridControl.ItemsSource>
    <dx:PagedAsyncSource ElementType="local_issues:Issue" KeyProperty="Id"
                         PageNavigationMode="ArbitraryWithTotalPageCount" FetchPageCommand="{Binding FetchPageCommand}"

wpf-data-grid-bind-to-pagedasyncsource/CS/PagedAsyncSourceMVVMSample/MainWindow.xaml#L18

xml
<dxg:GridControl.ItemsSource>
    <dx:PagedAsyncSource ElementType="{x:Type local:IssueData}"
                         PageNavigationMode="ArbitraryWithTotalPageCount"

Inheritance

Object DispatcherObject DependencyObject ContentElement FrameworkContentElement DXFrameworkContentElement VirtualSourceBase PagedSourceBase PagedAsyncSource

See Also

PagedAsyncSource Members

DevExpress.Xpf.Data Namespace