ASP.NET VERSIONS: 3.5
Head Toward the Light
Getting Started with Silverlight 1.0
By Dan Wahlin
The overall acceptance of AJAX and Flash technologies in Web applications has led to the creation of more and more rich applications that provide an enhanced next generation user experience. End users are accustomed to visiting Web sites that show advertisements and media clips with Flash and load dynamic content with AJAX. With the release of Silverlight 1.0, Microsoft has thrown their hat into the rich Web experience ring and provided a nice foundation for developers to build upon. Silverlight works on Windows and Mac operating systems, and in multiple browsers, including Internet Explorer, FireFox, and Safari.
If you ve heard about Silverlight, but haven t yet had a chance to experiment with it, it s a browser plug-in that can play audio and video, perform animations and transformations, and enhance the way data is displayed in a Web page. You can download the plug-in and associated software development kit (SDK) and view many eye-catching Silverlight demos at http://silverlight.net.
Putting the Pieces Together
Silverlight has several key technology players that are needed to make things work in a Web page. First, XAML is used to define the content displayed by Silverlight. XAML is an XML-based mark-up language that also is used by Windows Presentation Foundation (WPF). The version of XAML available in Silverlight 1.0 contains a sub-set of the overall XAML specification, as the Silverlight plug-in needs to stay small to allow for quick downloads and installations. Using XAML, you can define shapes, such as rectangles and ellipses, embed .wmv and .wma media files, perform snazzy animations to move objects around, and transform objects to perform interesting effects. I ll provide an introduction to XAML in the next section of the article.
Figure 1 shows the overall Silverlight architecture as defined in the Silverlight 1.0 SDK. You ll see that it provides support for decoding media, working with events, rendering content and text, parsing XAML, downloading objects used by Silverlight, performing animations, plus more.
Figure 1: The architecture of Silverlight 1.0.
Now that you ve seen the main Silverlight components, let s see how they work together. The basic steps to use Silverlight in a Web page are shown here:
1) Create a new Web site in Visual Studio or Web Developer Express.
2) Add the Silverlight.js file to the Web site.
3) Create an XAML file that Silverlight will consume.
4) Add a Web page with a
5) Add a custom CreateSilverlight.js file to the site.
6) Call Silverlight.createObject or Silverlight.createObjectEx within CreateSilverlight.js to create a Silverlight instance at run time.
7) Reference the Silverlight.js and CreateSilverlight.js files in the Web page using the