Chapter 14. Dealing with Data

One of the most prominent and compelling aspects of rich Internet applications is unfettered access to data. It should, therefore, be no surprise that Silverlight provides a rich, pervasive model that allows you to create dynamic data-driven applications. Silverlight provides a host of facilities for retrieving, displaying, manipulating, and storing data from a variety of data sources.

In this chapter you will discover:

  • How to expose data from a server and retrieve it from a Silverlight application

  • How to present data via the XAML-binding syntax

  • How to store data on the client

Getting Data to Your Application

If you are accustomed to using classes within Sytem.Data to query databases directly, you are in for a rude surprise with Silverlight, as none of these services are available. Instead, the WebClient class is provided to make network requests to arbitrary URI data endpoints. Fortunately, Microsoft also provides the infrastructure to generate WCF proxy client classes, which take care of the details needed to access data you expose through WCF services.

Fetching Data with the WebClient Class

You can use the WebClient class to retrieve data from a wide variety of endpoints including POX-, JSON-, RSS-, and REST-based services. All requests are performed asynchronously in Silverlight, which enables your application to respond even while loading data.

Depending on the format of the data returned by a server, you then choose the appropriate class to parse it into ...

Get Silverlight™ 3 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.