Part 1 > Setup database, create entity data model, create a simple domain service, and expose OData end points
Part 2 > Consume OData Endpoints using Internet Explorer [or any other client] for that matter
Part 3 > Consume entities exposed using RIA services with Silverlight [code behind]
Part 4 > Consume entities exposed using RIA services with Silverlight [declaratively using XAML]
Part 5 > Write a converter that shows the text Loading… while the data is loaded in the background
In this part, let's figure out how easy it is to introduce paging for the DataGrid.
Albums.xaml now looks as follows…
<navigation:Page x:Class="ChinookSample.Views.Albums"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ria="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
xmlns:service="clr-namespace:ChinookSample.Web.Services"
xmlns:helper="clr-namespace:ChinookSample.Helpers"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="Albums Page" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot">
<Grid.Resources>
<helper:BooleanToVisibility x:Key="BoolToVisibility" />
</Grid.Resources>
<ria:DomainDataSource Name="source" AutoLoad="True" LoadSize="50"
QueryName="GetSortedAlbums">
<ria:DomainDataSource.DomainContext>
<service:dsAlbumAndArtist />
</ria:DomainDataSource.DomainContext>
</ria:DomainDataSource>
<ScrollViewer Margin="2" MinHeight="500" VerticalAlignment="Top">
<StackPanel>
<sdk:DataPager x:Name="AlbumsPager" Margin="10,0,10,0" PageSize="10"
Source="{Binding ElementName=source, Path=Data}" />
<sdk:DataGrid Margin="10,2,10,2" Name="gridAlbums"
ItemsSource="{Binding ElementName=source, Path=Data}">
</sdk:DataGrid>
</StackPanel>
</ScrollViewer>
<TextBlock Height="49" Text="Loading..."
VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32"
Visibility="{Binding ElementName=source, Path=IsLoadingData,
Mode=TwoWay, Converter={StaticResource BoolToVisibility}}" />
</Grid>
</navigation:Page>
Notice > The changes are subtle. First up, a ScrollViewer is introduced along with StackPanel.
Notice > DataPager control is introduced and its PageSize is set to 10. Also notice that the Source binding for DataPager is exactly the same as of DataGrid's ItemSource binding.
One important thing that you may notice when you run this application is that the interface will be much faster when it loads. That's because LoadSize is set to 50 for DomainDataSource.
I am assuming you are following every step of these posts… if not… here is a refresher from the last post…
"Also notice LoadSize is set to 50. This will ensure that the data is loaded in chunks of 50. Hence, the Loading… status should appear and disappear every time the data is loaded. Remove this attribute, and see how Loading… disappears once done. Then put this attribute back and see how Loading… switches between visible/invisible every time it goes to fetch the data."
When you run this application, you will get an interface like the following… Loading… text block will appear and disappear quickly.

Paging would work as expected. Press the next button 4 times. This way you would be on the 5th page, and the response will be immediate. The moment you press the button 5th time, you will see Loading… text block will appear, 50 more records will be loaded instantly and you will be taken to the Page 6.

Hence, you can see that just by using Data Pager control, you have inherently stopped your interface to pull down more data than actually required by using LoadSize for DomainDataSource.
In the next post, you will find out how to pass parameters to the Query. Stay tuned!
Until next time,
Rahul
Quote of the day:
There are two motives for reading a book: one, that you enjoy it; the other, that you can boast about it. - Bertrand Russell