Top 10 Things to Know About Silverlight

Introduction

Silverlight is the Microsoft portal for developing Rich Internet Applications (RIA). Until now Microsoft has released many versions of Silverlight, each version has been bundled with a lot of new features. The latest of them is Silverlight ver. 4.0. For more introductions, tutorials, blogs or videos visit the official Silverlight website http://www.silverlight.net/.

In this article we’ll highlight the top 10 things to know about Silverlight.This would help developers who are relatively new to the Silverlight platform to understand how SIlverlight works. This top 10 section does not include the information about the Silverlight platform for mobile devices.

Silverlight SDK

This is a first and foremost candidate for the developers to be aware of. As the name suggests it is the software development kit for developing Silverlight applications using Microsoft Visual Studio. It contains the samples, documentation, libraries and tools to develop Silverlight applications.

Silverlight development is supported in Microsoft Visual Studio 2005, 2008 & 2010. If you are using Microsoft Visual Studio 2005 or 2008 then you need to download and install Silverlight SDK explicitly. In case you have installed Microsoft Visual Studio 2010 then you don’t have to worry about it because Silverlight comes by default.

For downloading the latest version of Silverlight SDK here.

Silverlight Project Structure

Normally when creating a new Silverlight application project in Microsoft Visual Studio it would create two projects. The project which has the XAML files is the Silverlight client and the other project would be a web application which would act as a host for the Silverlight client. The developers can also create Silverlight libraries that gives the provision to use them on multiple web host applications.

Fig 1.0 shows the sample Silverlight application structure.

screenshot of the project template
Fig 1.0

Hosting Silverlight Applications on Web Pages

You could also create the Silverlight project without a host web project. But even then when you run the Silverlight client you would notice the content getting hosted implicitly onto a web page by Microsoft Visual Studio.

As the Silverlight application is built with XAML it cannot be delivered to the end user’s browser directly. This is the reason for which a hosting web page is required.

The Silverlight content can be hosted on any type of web pages from HTML, aspx to Java and PHP. Below is the content on the web page which is required for hosting the Silverlight content onto it.

  <script type="text/javascript" src="Silverlight.js"></script>
  <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
  		  <param name="source" value="ClientBin/SilverlightApplication1.xap"/>
  		  <param name="onError" value="onSilverlightError" />
  		  <param name="background" value="white" />
  		  <param name="minRuntimeVersion" value="4.0.50826.0" />
  		  <param name="autoUpgrade" value="true" />
  		  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
   			  <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
  		  </a>
  </object>

All the Silverlight windows would use the same web page for displaying their content. There should be a start up or an entry point window in the Silverlight client.

Silverlight Based Application Package

The extension of the Silverlight application package is .XAP. The XAP file is generated as a result of building the Silverlight client application. This file is the one which will be hosted onto the web page. When the user requests a Silverlight application through web this .XAP file would be streamed to the client and stored in a separate workspace. This makes Silverlight as a powerful RIA.

The contents of the .XAP files are the .ddl files of the Silverlight client application and an AppManifest.xml file. The AppManifest.xml contains the dll information, entry point information, etc.

XAP is of a compressed .zip format which leads the content to be extracted by changing the extension to .zip.
When you build the Silverlight application in Microsoft Visual Studio 2010 you would notice the XAP file is placed under the folder called ClientBin on the Web project as shown in Fig 2.0.

the sample Silverlight application structure
Fig 2.0

More by Author

Must Read