Search code examples
silverlightsilverlight-3.0wcf-ria-servicesdatapager

DataPager not working in Silverlight 3 + RIA Services


I have a Silverlight 3 app with RIA Services and I'm running into an issue where my DataPager is only loading data for the initial loadsize and then no longer reloading. It brings up two pages of data (PageSize=10, LoadSize=20.) It is correctly showing 119 pages of data but when I navigate to page 3, nothing appears in my datagrid and dataforms.

This is my Domain Data Source:

<riaControls:DomainDataSource x:Name="_dds" QueryName="GetCaseLoads" AutoLoad="True" PageSize="10" LoadSize="20">
    <riaControls:DomainDataSource.DomainContext>
        <domain:FooContext />
    </riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>

Here's the snippet for the DataPager:

<data:DataPager Source="{Binding Data, ElementName=_dds}" />

And here's the Domain Service query:

[RequiresAuthentication()]
public IQueryable<CaseLoad> GetCaseLoads()
{
    // Return all case loads
    return this.Context.CaseLoadSet;
}

It's pretty straightforward so I'm not sure what's missing. Any help would be appreciated;


Solution

  • After spending way too much time trying to get this working I FINALLY figured out the problem, which I think is more of a bug with the RIA Services technology because I should have gotten some kind of warning message about this.

    The simple fix is to order the collection being returned by GetCaseLoads(). I did it like this and it worked:

    [RequiresAuthentication()]
    public IQueryable<CaseLoad> GetCaseLoads()
    {
        // Return all case loads
        return this.Context.CaseLoadSet.OrderBy(caseLoad=>caseLoad.fkUserId);
    }
    

    Amazing how much time solving this little problem took.