RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Application Development Tips with Silverlight 4 Tools

Take advantage of Silverlight 4 and Windows Communication Foundation 4 to bind data to Silverlight Data Controls.

Silverlight is a great tool that you can use to work with data retrieved from different services. With some knowledge of asynchronous programming and callbacks, you can use Silverlight to develop applications that are bound to data retrieved from different services that can scale over time. This article presents a brief overview of WCF and Silverlight and discusses how they can be used in application development to design and implement applications that can scale over time with intuitive user interfaces.


To work with Silverlight 4 and Windows Communication Foundation 4 you should have the following installed in your system:

  • Visual Studio 2010
  • Silverlight 4 Tools for Microsoft Visual Studio 2010
To take advantage of the concepts discussed in this article, you should be familiar with all of the following:

  • Microsoft Visual Studio 2010
  • C# Programming Language
  • .NET Framework 4.0
  • Basic knowledge of Silverlight and/or WPF

Introducing Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF) is a platform that can be used to design and implement platform independent, scalable services and provides support for unification of a number of enterprise technologies under one roof. The MSDN states, "Windows Communication Foundation (WCF) is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments." Reference: http://msdn.microsoft.com/en-us/library/ms735119.aspx

Note that WCF was introduced as part of .NET Framework 3.0 in 2006 and was initially named "Indigo". WCF 4 is now available as part of Visual Studio 2010.

Windows Communication Foundation 4.0 includes a lot of interesting new features. These include:

  • Support for Simplified Configuration
  • Support for Standard Endpoints
  • Support for Discovery
  • Support for Simplified IIS Hosting
  • Enhanced Support for REST
  • Support for Routing service
  • Support for Workflow services

Silverlight 4 -- A Quick Look

Silverlight is a browser plug-in that promotes a collaborative development environment of rich online media content that enables developers and designers alike to integrate multimedia and graphics into web pages within the context of the managed environment. Over the past few years, Silverlight, formerly known as Windows Presentation Foundation Everywhere (WPF/E), has become popular worldwide for developing the next generation of cross-browser, cross-platform Rich Internet Applications (RIAs).

Silverlight 4 provides a lot of interesting new features that help developers to build cutting edge applications with awesome multimedia and graphics. You now have support for printing, rich reporting and charting, support for web camera and microphone, support for COM automation, support for local file access, support for new languages, rich text editing, and, improved support for data binding to name a few.

Data binding Silverlight 4 Controls using WCF

Data binding is a term that implies binding data retrieved from a data source to data controls. You can use WCF Data Services to create and consume OData services for the web seamlessly. Microsoft states: "The Open Data Protocol, referred to as OData, is a new data-sharing standard that breaks down silos and fosters an interoperative ecosystem for data consumers (clients) and producers (services) that is far more powerful than currently possible. It enables more applications to make sense of a broader set of data, and helps every data service and client add value to the whole ecosystem." Reference: http://msdn.microsoft.com/en-us/data/aa937697

WCF Data Services (previously known as ADO.NET Data Services), provides support for the Open Data Protocol in a managed environment. To bind data to Silverlight 4 controls using WCF, you should follow the steps outlined below:

  1. Create a new application in Visual Studio 2010.
  2. Select the project you have created in the solution explorer and click "Add New Item"
  3. Select ADO.NET Entity Data Model from the list of the project templates displayed
  4. Specify the data connection as needed and select the AdventureWorks database
  5. To expose the data retrieved through the Entity Data Model for the AdventureWorks database, create a new WCF Data Service
  6. Configure your data service accordingly so that it can be used to pull data out of the AdventureWorks database

Your data service code would look like as shown in the code snippet below:

public class MyDataService : MyDataService<AdventureWorksEntities>

   public static void InitializeService(DataServiceConfiguration config)
      config.SetEntitySetAccessRule("*", EntitySetRights.All);
      config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date