About this book – Silverlight 2 in Action, illustrated edition

About this book

The overall goal of this book is to inform and educate you on the exciting and powerful Silverlight 2 platform. Think of this book as a guided tour through the Silverlight 2 SDK. After you’ve completed this book, you should be able to confidently design, develop, and deliver rich interactive applications using Silverlight. To facilitate the learning process, we’ve structured this book to get you developing valuable applications as fast as possible, while providing quality, in-depth content.

Within each chapter, we’ve included a collection of devices to help you build a firm understanding of Silverlight. The following list explains how each agent helps along the journey:

  • FigureVisual depictions that summarize data and help with the connection of complex concepts.
  • SnippetSmall, concise pieces of code primarily used for showing syntactical formats. These individual segments generally can’t be run on their own.
  • TableEasy-to-read summarizations.

In addition to these valuable learning devices, we’ve created a companion website, the best tool of all. The http://www.silverlightinaction.com website will provide all the code samples used in this book. In addition, you’ll be able to run these code samples directly from your browser! This website will also expose a number of web services and other items that you can use to try out the material you learn in this book.

As an added bonus, several chapters will contain an optional “Blending it together” section. This section gives you the opportunity to gain experience with two of Microsoft’s powerful creative tools: Microsoft Visual Studio 2008 and Microsoft Expression Blend 2. Both of these tools are optional for Silverlight development, but, because they’re available as a free trial via the Microsoft website, and they provide such a powerful development experience, we’ll use them as part of our gear for this journey.


This book is intended for developers with a desire to create rich, valuable, web-based user experiences with Microsoft Silverlight 2. Silverlight definitely provides great opportunities for designers. But, this book is aimed at our friends and colleagues that focus primarily on the development side of software solutions.

This book assumes that you’re familiar with common web standards such as HTML, CSS, and JavaScript. In addition, this book assumes that you have a background using the .NET Framework and Microsoft Visual Studio. Although we’ll be using C#, we won’t be reviewing the C# language or explaining basic programming constructs such as classes, methods, and variables.

The gear: what you need

This book provides a lot of opportunity for hands-on learning. But, it also provides a great deal of flexibility by allowing you to learn the material without using the hands-on content or optional tools. If you desire to get the greatest value out of this book and use the hands-on opportunities, the following tools are recommended:

  • Silverlight 2 (required)
  • Microsoft Visual Studio 2008 SP1 (recommended)
  • Microsoft Expression Blend 2 (recommended)
  • Microsoft ASP.NET Futures (recommended)

We’ve made conscientious attempts to ensure that the information and screenshots are consistent with the product versions mentioned above. But, to alleviate any confusion that may arise from inconsistencies, here’s the list of tools used over the course of a 15–month period to create this book:

  • Silverlight 1.1 Alpha, Silverlight 2 Beta 1, Silverlight 2 Beta 2, and finalized on Silverlight 2 RC0
  • Microsoft Visual Studio 2008
  • Microsoft Expression Blend 2.5—August Preview, September Preview, December Preview, and finalized on the June Preview
  • Microsoft Windows XP with Service Pack 2 and Microsoft Windows Vista

If you’re new to these tools, this list may be somewhat overwhelming. If you’d like a guided approach, please visit the http://silverlight.net/GetStarted/site. Now, that you have the gear, let’s look at the map of our journey.


This book is designed to give you a guided tour of Silverlight. This tour will focus on Silverlight’s rich client-side features. These features will be covered over the course of twelve chapters.

Chapter 1 introduces Silverlight. This introduction shows you the advantages of Silverlight. In addition, you’ll be introduced to the powerful developer/designer collaboration available in Silverlight. Finally, this chapter will show you some of the core concepts of the markup language used by Silverlight: XAML.

Chapter 2 details Silverlight’s relationship with HTML. This chapter will show you how to create an instance of the Silverlight plug-in and add it to a web page. In addition, you’ll learn about the HTML and Silverlight Object Models. Finally, this chapter will show you how to manage the HTML DOM with Silverlight.

Chapter 3 covers the basics of any presentation technology: layout and text. In addition, you’ll see the core UI features used throughout Silverlight.

Chapter 4 deals with user interaction via input devices and form controls. You’ll learn about drag-and-drop implementations and the massive control library. This chapter will also provide a description of dialog boxes in Silverlight.

Chapter 5 discusses three important topics related to data. First, you’ll learn about the intricacies surrounding data binding. Then, you’ll see the heavily used DataGrid in action. Finally, this chapter will discuss the powerful and distinguishing LINQ feature.

Chapter 6 covers the communication and networking features of Silverlight. You’ll see how these features empower you to connect to SOAP and REST-based services. You’ll also learn to use data in the form of POX, JSON, and syndicated feeds. Finally, you’ll learn about more advanced WCF duplex services and TCP sockets.

Chapter 7 gets back to the roots of Silverlight: media. This chapter covers interactive playback features. Then, you’ll see some of details surround client- and server-side playlists. This chapter will also cover the imaging features of Silverlight, including the incredible Deep Zoom functionality.

Chapter 8 tackles the graphics features embedded within Silverlight. You’ll learn about basic shapes and geometries. Then, you’ll see the powerful features stored within the various brush types. Finally, this chapter will show you how to transform any element in Silverlight.

Chapter 9 addresses the lively animation features of Silverlight. Over the course of this chapter, you’ll learn about the basics of creating animations. Then, you’ll learn how to interact with those animations.

Chapter 10 deals with styling the visual elements of Silverlight. This chapter includes the rich styling and templating features. This chapter will conclude with a discussion surrounding the flexible VisualStateManager.

Chapter 11 moves away from the UI and details some of Silverlight runtime features. You’ll learn about isolated storage and asynchronously running tasks. You’ll also see how to retrieve content on the fly. Finally, you’ll see an analysis on the Dynamic Language Runtime (DLR).

Chapter 12 discusses sharing your Silverlight creations with the world. This includes user control development and navigation implementation. You’ll also learn about creating a custom splash screen. Finally, you’ll get an introduction to the cloud-based Silverlight Streaming service.

Code conventions

All the code used in this book will be presented in a monospace font. This code can be in one of a variety of languages. Because of this approach, the language will be listed vertically along the left edge of the snippets. For longer lines of code, a wrapping character may be used to be technically correct while forming to the limitations of a printed page.

Author Online

The purchase of Silverlight 2 in Action includes free access to a private forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and other users. You can access and subscribe to the forum at http://www.manning.com/Silverlight2inAction. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct in the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It isn’t a commitment to any specific amount of participation on the part of the authors, whose contributions to the book’s forum remain voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

In addition to the Author Online forum available on Manning’s website, you may also contact us regarding this book, or anything else, through one of the following avenues:

All comments sent to these blogs are moderated. We post nearly all comments; but, if you include your email address or phone number, we won’t post the comment out of respect for your privacy.

About the authors

Chad Campbell is a Microsoft MVP and solutions architect. He has been developing enterprise-level web applications with a wide variety of technologies since 1999. Beginning with the initial public release of what would become Silverlight in 2006, Chad hit the ground running and hasn’t looked back. He holds MCSD and MCTS certifications. In addition, Chad has a BS degree from Purdue University where he focused his studies on computer science and minored in psychology.

John Stockton has been developing advanced web applications using Microsoft technologies for Fortune 500 companies and government agencies for the last decade. He’s very active in the local community by speaking at and organizing events and is also an active member of the online Silverlight community. In his free time John enjoys model railroading, woodworking, being active outdoors, and playing with his two-year-old son.

About the title

By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during self-motivated exploration.

Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent it must pass through stages of exploration, play, and, interestingly, retelling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action book is that it’s example-driven. It encourages the reader to try things out, to play with new code, and explore new ideas.

There is another, more mundane, reason for the title of this book: our readers are busy. They use books to do a job or solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want just when they want it. They need books that aid them in action. The books in this series are designed for such readers.

About the cover illustration

The figure on the cover of Silverlight 2 in Action is a “Janissary in Dress of Ceremony.” Janissaries were the personal troops and bodyguards of the Ottoman sultan. The illustration is taken from a collection of costumes of the Ottoman Empire published on January 1, 1802, by William Miller of Old Bond Street, London. The title page is missing from the collection and we have been unable to track it down to date. The book’s table of contents identifies the figures in both English and French, and each illustration bears the names of two artists who worked on it, both of whom would no doubt be surprised to find their art gracing the front cover of a computer programming book…two hundred years later.

The collection was purchased by a Manning editor at an antiquarian flea market in the “Garage” on West 26th Street in Manhattan. The seller was an American based in Ankara, Turkey, and the transaction took place just as he was packing up his stand for the day. The Manning editor did not have on his person the substantial amount of cash that was required for the purchase and a credit card and check were both politely turned down. With the seller flying back to Ankara that evening the situation was getting hopeless. What was the solution? It turned out to be nothing more than an old-fashioned verbal agreement sealed with a handshake. The seller simply proposed that the money be transferred to him by wire and the editor walked out with the bank information on a piece of paper and the portfolio of images under his arm. Needless to say, we transferred the funds the next day, and we remain grateful and impressed by this unknown person’s trust in one of us. It recalls something that might have happened a long time ago.

The pictures from the Ottoman collection, like the other illustrations that appear on our covers, bring to life the richness and variety of dress customs of two centuries ago. They recall the sense of isolation and distance of that period—and of every other historic period except our own hyperkinetic present.

Dress codes have changed since then and the diversity by region, so rich at the time, has faded away. It is now often hard to tell the inhabitant of one continent from another. Perhaps, trying to view it optimistically, we have traded a cultural and visual diversity for a more varied personal life. Or a more varied and interesting intellectual and technical life.

We at Manning celebrate the inventiveness, the initiative, and, yes, the fun of the computer business with book covers based on the rich diversity of regional life of two centuries ago, brought back to life by the pictures from this collection.