Creating the Client Application

Once you have created the Server Application, you may start developing the Client one.

To display the data from the WCF Data Service, create a new Silverlight application with a data source that is based on the service. Later in this walk-through, you will add data-bound controls to the application.

  1. In Solution Explorer, right-click the solution node, click Add, and select New Project.

  2. In the New Project dialog, expand Visual C# or Visual Basic, and then select Silverlight.

  3. Select the Silverlight Application project template.

  4. In the Name box, type NorthwindExplorer and click OK. The New Silverlight Application Wizard opens.

  5. Uncheck the Web site check-box and click OK. Visual Studio adds the NorthwindExplorer project to the solution. Rad Data Service Data Source newsilverlightapplication 01

  6. On the Data menu, click Show Data Sources. The Data Sources window opens.

  7. In the Data Sources window, click Add New Data Source. The Data Source Configuration Wizard opens.

  8. In the Choose a Data Source Type page of the wizard, select Service and then click Next.

  9. In the Address box, type and then click Go.

  10. Visual Studio searches the specified address for available services, and adds NorthwindEntities to the list of available services in the Services box.

  11. In the Namespace box, type NorthwindService.

  12. In the Services box, click NorthwindEntities and then click OK. Visual Studio downloads the service information and then returns to the Data Source Configuration Wizard.

  13. In the Add Service Reference page, click Finish. Visual Studio adds nodes that represent the data returned by the service to the Data Sources window.

  14. On the Project menu, click Add Class.

  15. Change the name to MyNorthwindContext, and click Add.

  16. Replace the class declaration with the following code:

public class MyNorthwindContext : NorthwindEntities 
 public MyNorthwindContext() : base(new Uri("", UriKind.Absolute)){} 
Public Class MyNorthwindContext 
 Inherits NorthwindEntities 
 Public Sub New() 
  MyBase.New(New Uri("", UriKind.Absolute)) 
 End Sub 
End Class 

When we added the Service Reference, Visual Studio generated a hidden file that contains all client-side proxy classes. You can find this file if you tell the Solution Explorer to “Show All Files” and then drill-down in the Service References node all the way to the file called Reference. When you use the Add Service Reference dialog to add a data service to an application, an entity container class is created that inherits from the DataServiceContext class. This class includes properties that return typed DataServiceQuery instances. In this case this class is called NorthwindEntities and we have further derived from it in order to specify the Uri where it should get its data from. This was done so we can easily declare RadDataServiceDataSource.DataServiceContext in XAML later on.

Silverlight RadDataServiceDataSource Project Structure WCF

See Also

In this article