Thursday, October 23, 2008

Simple Rich User Experience with SilverLight 2.0

In this post i am going write a Silver Light client consumes the WCF Service which has the Operation contract called GetCustomers that returns a list of customers from NorthWind Database. This SL 2.0 client supports pagination of the Customers records with Slider Controls.


Step to Create the Application


1) Create a Silver Light Application (web).

2) Add WCF service template or Silver Light-enabled WCF service template to Silver Light Application Testing project.




3) Add OperationContract called GetCustomers in Service.cs.

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace DBPagenation.Web
{
// NOTE: If you change the interface name "ISreeniDataService" here, you must also update the reference to "ISreeniDataService" in Web.config.
[ServiceContract]
public interface ISreeniDataService
{

[OperationContract]
List GetCustomers(int pageNumber);
}
}


4) Add LINQ to SQL Classes and create a data class by dragging Customers table from server Explorer. And change the serialization mode properties to Unidirectional. This properties make data class as realizable [DataContract].






Silver Light UI CODE:







using Slider control now navigate different pages of customer records instead of clicking old style like 1 2 3 4 5...

Thanks
SeenivasaRagavan

No comments: