How to use datapager control in Silverlight 5.0 application?
Are you new to Silverlight 5.0 ? Then this article may help you to get out of fear of development in Silverlight 5.0. Read more about the datapager control for Silverlight.
How to use datapager control in Sliverlight 5.0 application?
Usage: If you want to go to and fro of page by using datapager control then the following code will be helpful for you.
I have used listbox control and added various skillset names in listbox. Now I have bound datapager in such a way that when you click on next page in datapager control, you will find items page by page.
Create Silverlight 5.0 application and put following code in Main.xaml.csusing System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
List
itemList.Add("C#");
itemList.Add("ASP.net");
itemList.Add("Java");
itemList.Add("COBOL");
itemList.Add("PASCAL");
itemList.Add("XML");
itemList.Add("ASP");
itemList.Add("SAP");
itemList.Add("VB.net");
itemList.Add("C");
itemList.Add("C++");
itemList.Add("VB");
itemList.Add("JSP");
itemList.Add("EJB");
itemList.Add("Silverlight");
itemList.Add("Sharepoint");
itemList.Add("DW");
itemList.Add("Testing");
PagedCollectionView itemListView = new PagedCollectionView(itemList);
dataPager1.Source = itemListView;
listBox1.ItemsSource = itemListView;
}
}
}
Put following code in Main.xaml
<UserControl x:Class="SilverlightApplication1.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot" Background="White">
<sdk:DataPager Height="26" HorizontalAlignment="Left" Margin="12,179,0,0" Name="dataPager1" PageSize="10" VerticalAlignment="Top" Width="186" />
<ListBox Height="158" HorizontalAlignment="Left" Margin="12,12,0,0" Name="listBox1" VerticalAlignment="Top" Width="187" ItemsSource="{Binding}" />
</Grid>
</UserControl>