Top 10 Things to Know About Silverlight

by V.N.S Arun

Silverlight is the Microsoft portal for developing Rich Internet Applications (RIA). This article aims at exposing the top 10 things developers need to know about Silverlight.


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"/>

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

Silverlight Plug-in

Once the XAP file is downloaded to the client machine the tool which is responsible for executing the Silverlight content and displaying the Silverlight content on the browser is the Silverlight plug-in. This is a free plug-in from Microsoft as this has to be installed on the client machines in order for the end user to get the Silverlight application to show up on the browser.

The Silverlight plug-in contains the core Silverlight CLR component whose default location on the client machine is C:\Program Files\Microsoft Silverlight\ 4.0.50401.0.

The Silverlight plug-in identifies the client DLLs and the entry point assembly using the AppManifest.xml file in XAP. If the user has not installed the Silverlight plug-in then he will be prompted for the installation on access of a Silverlight application.

Silverlight.js File

If you notice the Silverlight package hosting web page you would find a JavaScript file added to it called Silverlight.js. This file is responsible to initiate the Silverlight plug-in. The createObject and createObjectEx can be called explicitly on the web page.

Multimedia Support

Most people prefer Silverlight in order to leverage its media support. Silverlight application has a rich support for multimedia. The MediaElement control is the one to do the trick. All the developer needs to do is simply drag -n- drop the MediaElement and point a media file available on the server to it. A lot of customization can be done to this MediaElement control in XAML. In fact a good looking media player can be developed and embedded into the application.

Below is a sample XAML code.

  <MediaElement Width="472" Height="328" Source="MyVideo.wmv">

Animation Support

As Silverlight uses XAML as the designer which is that same for WPF it is evident that Silverlight exposes a rich set of animation support. You could also define storyboards onto Silverlight windows.

For an in-depth look on Silverlight animation check the MSDN.

WCF RIA Services

WCF RIA services are available in .NET Framework 4.0 which eases the task of sharing the business logic and business objects between the Silverlight client and the server project in a WCF manner. Without this feature in order to share the business logic / entities between the client and server projects the developer would end up in writing duplicate code at both places.

Availability Silverlight Business Application Template

Silverlight 4.0 on Microsoft Visual Studio 2010 is supplemented with the Silverlight business application template. A Silverlight business application project when created, adds up all the generic things that has to be created for a business application like Login, styles, navigation, commonly used controls, etc. Fig 3.0 shows the screenshot of the project template.

Fig 3.0

A lot of effort is saved while developing a true business application.


Hope this article clearly highlights the top 10 things to know about Silverlight. This top 10 list is purely based on my own instincts. As a reader if you have any contradiction then please use the comments section to emphasize it.

Happy Coding!

Related Articles

This article was originally published on Monday Jan 24th 2011
Mobile Site | Full Site