Silverlight 2 introduced support for .NET code in Silverlight applications, but that is not the only major improvement it offered. Table 1-1 lists many of the major improvements to Silverlight 2, including several that are integral to developing data-driven applications with Silverlight. Table 1-1 singles out these specific features, as it is important to be aware of how they can help developers build solid, data-driven applications with Silverlight 2.
Table 1-1. Key Silverlight 2 features
New features in Silverlight 2 | Notes |
---|---|
Framework languages and .NET support | Silverlight 2 includes a portion of the .NET Framework, and supports Visual Basic, Visual C#, IronRuby, and IronPython. |
Data binding and notifications | XAML-based data binding
and notifications through the |
Isolated storage | Silverlight 2 can store information in a protected area on a client computer. |
Contractual and noncontractual data services: JSON, REST, SOAP, POX, and Atom-based RSS web services | Various data services are accessible via Silverlight 2. This makes reading data from web services simple. |
Cross-domain network access | Silverlight 2 can access services that do not originate from the server hosting the Silverlight 2 application. |
LINQ, lambdas, extension methods, and object initializers | LINQ to Objects, LINQ to XML, and LINQ to JSON are included in Silverlight 2 to define queries against complex data structures. |
| Silverlight 2 introduces support for the three major layout panels native to WPF and XAML. |
Suite of bindable controls and panels | Silverlight 2 introduces a wide array of controls that you can integrate into Silverlight 2 applications and bind to data sources. |
Note
Originally, Microsoft was going to release Silverlight 2 as Silverlight 1.1, but with all of the improvements it made to the application, the company deemed the new version to be different enough to warrant its own major release number.
Looking at the new features in Table 1-1, it is obvious that Silverlight 2 boasts a lot of major new capabilities. It is important to touch on each enhancement that directly affects data-driven application development. We will explore many of these thoroughly in upcoming chapters, so for now I’ll cover them only briefly to introduce you to them.
I cannot overstate the fact that developing a Silverlight application is much easier when you can leverage your existing .NET development experience. This starts with being able to write .NET code in the Silverlight client application to handle various aspects of that application, including event handlers, referencing the extensive .NET Framework, and creating complex user controls. The Silverlight 2 runtime contains a small but powerful subset of the .NET Framework library so that developers can take advantage of their .NET skills and transition to Silverlight 2 with minimal effort.
Silverlight 2 can communicate with SOAP-based web services (e.g., using WCF or ASMX) to pass defined data structures between a Silverlight client and a remote server. These services expose a contract through WSDL with which the client can communicate by generating proxy classes. This contract defines the services that you can call and how to call them, and it exposes the data structures that you can pass into and out of the services. This is key to exposing web services that return or accept serializable entities as parameters. With contractual data services, Silverlight 2 can communicate with remote services that return entities from LINQ to SQL, NHibernate, the ADO.NET Entity Framework, or even custom domain entity models. It also opens the door to being able to communicate with third-party SOAP-based services that expose WSDL, such as Live Search.
Silverlight 2 can also consume data services without generating proxy classes using SOAP, RSS, Atom, JSON, POX, or REST. Many sources of information are available that return data using a noncontractual service. For example, Digg.com, Amazon.com, Twitter.com, and Flickr.com all expose REST services that return XML. Silverlight 2 applications can request information from all of these services and integrate the results into an application. In Chapters 7–9, we will delve deeply into these areas, as well as discuss how to communicate with them across domains and how to manage the XML and JSON they may return via LINQ to XML and LINQ to JSON, respectively.
The new control model that Silverlight 2 provides makes it much
easier to write Silverlight 2 applications. You can organize the new
controls within the XAML layout panels, such as Grid
, Canvas
, and StackPanel
, to create rich interfaces. The
controls support XAML-based data binding and dependency properties,
which we will discuss in detail in Chapters 2–4.
Silverlight 2 introduced more than two dozen controls that you
can use to build Silverlight 2 client applications. It offers layout
panels such as Grid
, StackPanel
, and Canvas
, as well as several input controls
that you can customize using templates and styles. You can completely
replace the content of some of the controls to achieve a more complex
solution. For example, you can replace the header of a DataGrid
control with a series of controls
that allow you to sort the DataGrid
. Or you can replace a button’s
default look with another element such as an Ellipse
and fill it with another FrameworkElement
such
as an image. Chapters 2–4 will dive deeply into the controls
and explain how data binding works with them, as well as offer best
practices for binding and presenting data. Figure 1-1 shows the
controls available in Expression Blend 2 with SP 1 and Figure 1-2 shows the
controls available in Visual Studio 2008.
Silverlight 2 supports the use of LINQ to Objects, which can simplify the querying of data in arrays and collections in a Silverlight application. LINQ to XML (also supported in Silverlight 2 applications) is very useful when consuming noncontractual data services that return XML. The XML can be read into a variety of XML-consuming libraries, but consuming it with LINQ to XML’s objects allows you to query the XML using the familiar and powerful LINQ syntax. Also, with LINQ at your disposal you can combine XML and object data structures in the same LINQ query. Many of the examples in this book will use LINQ in some fashion to query data from XML or objects.
Get Data-Driven Services with Silverlight 2 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.