Wahlin on .NET
Getting Started with Silverlight
Dan starts a new series of columns on Silverlight 1.0 by walking you through the fundamentals.
Keeping up with the latest Web technologies can be a daunting task given the pace at which technologies emerge and evolve. Just when you think you've mastered a particular set of technologies, a new one comes onto the scene and adds to the fun.
Over the past few months, I've focused on ASP.NET AJAX features and capabilities and described how Microsoft's AJAX framework can be used to enhance the end user experience. Starting with this article, I'm going to switch gears and begin discussing Microsoft's Silverlight product, starting with Silverlight 1.0, which has been officially released and is now available for use. However, Silverlight 1.1 is already in the works, so I'll discuss that as it gets closer to release. Down the road, I'll revisit ASP.NET AJAX and explain how it can be used in conjunction with Silverlight 1.0 to supply Silverlight applications with data.
What Is Silverlight 1.0?
A lot of people like to compare Silverlight to Adobe's Flash product. Silverlight is a plug-in, like Flash, that must be installed on an end user's computer in order to work and can be used in multiple browsers including Internet Explorer, Firefox and Safari. Silverlight also works on multiple operating systems, including Windows and Macintosh (a Linux version called Moonlight is also being developed outside of Microsoft). Once installed, Silverlight can be used to provide eye-catching animations, display movies, show ads, provide navigation and play games or music.
XAML is also used to build Windows Presentation Foundation (WPF) applications. However, the XAML used in Silverlight is a more compact version than what's found in WPF. Listing 1 shows a simple XAML document that can be used with Silverlight to display and animate text. XAML uses <Canvas> elements for layout in a similar way that HTML uses <div> elements for layout. I'll provide additional details about writing XAML in future articles.
From="80" To="200" Duration="0:0:3"
Text="Hello, From Silverlight!">
So how do you get started using Silverlight? First, take some time to explore the Silverlight Web site. The site contains several tutorials and the Silverlight SDK (with help files and examples), as well as numerous demonstrations on using Silverlight. You should download the Silverlight SDK because it contains help documentation and quickstart samples that help lower the learning curve and get you up-to-speed more quickly on XAML and Silverlight concepts.
To create a Silverlight application, you can install the Silverlight tools for Visual Studio .NET (available on the Silverlight site here) or create a page from scratch. Here are the basic steps to follow if you want to create a Silverlight application from scratch. I'll provide more specifics on these steps in the next article.
Step 1: Create a new ASP.NET Web site in Visual Studio .NET 2005. Why should you create an ASP.NET Web site? You don't have to use ASP.NET at all because Silverlight can be hosted in a standard HTML page. However, by creating an ASP.NET Web site you'll be able to leverage ASP.NET AJAX and other ASP.NET technologies if needed, which can be useful when the application needs to retrieve data from services.
Step 3: Create a XAML file that contains the shapes, media, animations or transformations that the application should perform.
Step 4: Add an HTML or ASP.NET page into your Web site that will host the Silverlight control. This page will define a <div> container where the Silverlight control will be placed in the page.
I'll drill down into these steps in the next article and provide addition details about what the Silverlight.js file does. Until then, feel free to examine the downloadable code available with this article. It provides a simple starter Silverlight application that you can explore to learn the fundamentals.
Dan Wahlin (Microsoft MVP for ASP.NET and XML Web Services) is the founder of The Wahlin Group which specializes in .NET and SharePoint onsite, online and video training and consulting solutions. Dan also founded the XML for ASP.NET Developers Web site, which focuses on using ASP.NET, XML, AJAX, Silverlight and Web Services in Microsoft's .NET platform. He's also on the INETA Speaker's Bureau and speaks at conferences and user groups around the world. Dan has written several books on .NET including "Professional Silverlight 2 for ASP.NET Developers," "Professional ASP.NET 3.5 AJAX, ASP.NET 2.0 MVP Hacks and Tips," and "XML for ASP.NET Developers." Read Dan's blog here.