'd guess that everyone reading this magazine has heard of Silverlight. I'll also guess that not everyone has jumped at the opportunity to "play" with something that had been in beta. The good news is that Silverlight 1.0 is now released! I've spent a lot of time with Silverlight since Microsoft made the Community Technology Preview version available as WPF/E. There's a large gap between a web site without Silverlight and a web site that lets you experience the interactivity of Silverlight. Before you finish reading this article, I hope you'll realize how very easy it is to bridge that gap.
Silverlight is a small ActiveX control that gets instantiated in your web page—in some cases the page may instantiate more than one instance. During the instantiation, the control is told to take direction from an XML file. That's all there is to it! Everything else is wiring—getting the instantiation going—or syntax and learning how to "give directions" to the control.
To get the pieces necessary to add Silverlight to your web page, first go to http://www.silverlight.net
. Choose the Get Started menu. On the next page, under the section called "Download The Runtime And Tools," scroll down to "Software Development Kit" and click the link for the "Microsoft Silverlight 1.0 Software Development Kit."
Extract the files downloaded to a folder of your choice. There's plenty of information in there, including:
- QuickStart. When you finish this article, go through the QuickStart tutorial; you won't be disappointed.
- Silverlight.chm. This is the Help file documentation. Many sections have example code.
For the purposes of this article, you want the Silverlight.js file in the Resources folder.
The HTML File
So that everyone begins at the same level, here's a base HTML file for the starter page used in this article.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
First Silverlight Page
Save the code above to a file with an .htm
extension, and then either drag that file to a browser window or double-click the file in an Explorer window. You should see a browser window open and the text, "Hello World."
|Editor's Note: This article was first published in the Nov/Dec 2007 issue of CoDe Magazine, and is reprinted here by permission.|