Other Virtual Sources

  • 2 minutes to read

The How to Use Virtual Sources tutorial demonstrates how to bind to InfiniteAsyncSource. This topic describes other virtual sources' specificities.

Paged Sources

This section describes how to use the PagedAsyncSource or PagedSource.

IMPORTANT

The PagedSource is obsolete. Use the PagedAsyncSource instead.

Examples

Specificities

InfiniteSource / PagedSource

This section describes how to use the InfiniteSource or PagedSource.

IMPORTANT

The InfiniteSource and PagedSource are obsolete. Use the InfiniteAsyncSource and PagedAsyncSource instead.s

Examples

In the examples below, a data access object (IssuesContext) emulation is used instead of a web service emulation:

Specificities:

  • In addition to events demonstrated in the Fetch Data and Enable Scrolling topic, you have to handle the InfiniteSource.CreateSource (or PagedSource.CreateSource) and InfiniteSource.DisposeSource (or 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 obtaining 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 InfiniteSource.FetchRows (or PagedSource.FetchPage) handler, return a list of objects separately and specify the FetchRowsEventArgs.HasMoreRows (or FetchPageEventArgs.HasMoreRows) property:

    source.FetchRows += (o, e) => {
        var fetchRowsResult = FetchRows(e);
        e.Result = fetchRowsResult.Rows;
        e.HasMoreRows = fetchRowsResult.HasMoreRows;
    };