Chapter 7. Accessing Data


  • Working with XML using LINQ and the XmlReader object

  • Working with data binding and user interfaces

  • Dealing with data when it changes

  • Communicating with services (REST, WCF)

One of the most prominent and compelling aspects of rich Internet applications is unfettered access to data. Therefore, it should 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.

If you are accustomed to using classes within System.Data to query databases directly, you are in for a rude surprise with Silverlight, because none of these services are available. This chapter looks at how you can use Silverlight to deal with services, both ASP.NET Web Services and the newer Windows Communication Foundation services.

This chapter also looks at dealing with XML, data binding, and RESTful-based services — starting with working with XML.


WCF RIA Services is covered in Chapter 8.


Although a developer might actually enjoy seeing XML presented directly in an application, it is far more likely that you will need to massage the XML data into some strongly typed objects that will be presented to the user. For instance, you would probably not want to expose the end user to the raw XML presented in Listing 7-1.

Example 7-1. Raw XML

<?xml version="1.0" encoding="utf-8" ...

Get Professional Silverlight® 4 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.