If you are based in the US and had a chance to experience Olympics 2008 over the web on http://nbcolympics.com - you probably saw some of the power of Silverlight for immersive media experiences. Silverlight 2 Beta 2 enables much more than media experiences so let us look at some of these aspects in detail .

Let us start with the Application Model for Silverlight2. The install is a one-time (system wide) phenomenon and updates happen automatically to the runtime and would not require a browser restart. The instantiation of the Silverlight application can be done via the <object > tag or programmatically using the Silverlight javascript. On the server hosting the Silverlight content, the correct mime-type needs to be set (XAP - Application/x-silverlight-app). The application package contains the app.dll, business assembly and the manifest file. Once the XAP is loaded all the objects are available in memory - this implies less round-tripping, better performance. Offline scenarios can rely on the IsolatedStorage feature for building durable experiences. All Silverlight applications can use a splash screen which is composed of pure XAML and javascript. There are also events raised which can be handled as the Silverlight content is downloaded the first time around. There can be multiple plug-in instances per-page and one App-domain per instance. Exception handling can be done by using the plug-in's onError event.

Next, lets look at Controls. Silverlight ships with a rich and functional control set. For layout, the following controls are available - Canvas, Panel, StackPanel, Grid. Other feature controls include Button, Calendar, CheckBox, DataGrid, DateTimePicker, GridSplitter, Hyperlink, ListBox, Popup, Radio, Slider, Toggle, Tooltip and this list will continue to grow. Silverlight also has a strong partner ecosystem building domain specific controls. Another important aspect in using framework control is the ability to style and apply skins to the controls to get the desired rendering. Silverlight fully supports these mechanisms and shown below are examples of applying skins and styles to the TreeView control to change its look and feel. The first image is the normal rendering, the second image applies styling to change background and imagery and the final image shows the transformation of the Treeview control into a dial-based UI to highlight full control over the UI. There are also ASP.Net controls available based on Silverlight - such as MediaPlayer control and the XAML control.

image image image

Another important feature in this regard is the VisualStateManager which provides a notion of state and transition and supports visual transition along with minimizing state explosion. Silverlight also supports Animations  - changing the value of a property over time, use different animation (double/color/point/object) and interpolating(linear/discrete/spline) types. Animations can be defined both declaratively and programmatically.

Another key aspect for Silverlight is Media. The key tenets for  Silverlight in this space are - highest quality, lowest cost of operation, best overall user experience, and monetization. There is support for VC-1, WMV, WMA, mp3, and WMA 10 Pro. One of the most feature for media capabilities is the support for DRM, this is applicable for streaming content. The support for playlists allows for delivery of a set of assets to any user. The 3 primary types of playlist are

  • .asx - resides on the client PC, simple to author and deploy, the urls are exposed to the client, ad content can be skipped
  • .wsx - resides on streaming server, can hide location of assets from the client, seek/skip disabled
  • .isx - web playlist, requested from web server which returns obfuscated urls for client playlist, location of assets remains hidden

As Silverlight content is displayed in the browser - it is important to understand the Browser Integration capabilities. This feature allows for seamless communication between javascript and .Net in the browser. There are 3 core scenarios - .Net functions exposed in browser and called from within javascript, javascript code on Html page could come from .Net code-behind and manipulate the Xaml tree from javascript (this is supported in Silverlight 1.0 only) . A Silvelright object can be registered as scriptable and specific members can be attributed with [Scriptable Member] to enable calling from javascript. For manipulating the Html DOM the HtmlPage class can be used.

An important aspect of any application is Data, so let us look at this in Silverlight 2. The first thing you will notice is LINQ support - in addition to LINQ to Xml and LINQ to objects, we now have support for LINQ to JSON. There is also support for in-memory filtering and sorting, compile-time syntax checking and 2-way binding support. DataTemplates are used for UI representation of data and can exist in Content controls or Item control. DataGrid is the main control for data and it supports data-binding, scrolling, row selection, text/template.checkbox columns, skinning, editing, resizable rows and columns, auto-sizing for rows and columns, frozen columns, filtering, detail view etc.

Finally a web application warrants a strong Networking support, so let us look at the Silverlight 2 networking features. One of the primary things to take note of is the WebClient - this supports asynchronous, cross-domain access to network assets. The HttpWebRequest and HttpWebResponse classes are also available and provide fine grained control of Http messaging. This allows to consume existing form-based assets. Silverlight supports WCF based services for consumption. SOAP-based web services can expose WSDL and deploy the x-domain xml and ClientAccessPolicy.xml to support access from other servers. Socket based communications require a policy server to be defined. The first handshake with the policy server determines which ports/protocols acceptable to connect.

One fun feature I wanted to touch upon to get everyone excited around Silverlight is DeepZoom - see it in action here (zoom-in and out to see the feature in action. This really provides a seamless viewing and zooming experience for large images or sparse images (more resolution in some parts of the image than others). The way this functions is to load only required data for showing a specific part of the image. The lowest resolution tiles are shown first and then higher quality tiles blend in. The DeepZoom composer tool can be used to transform regular images to multi-scale images so that these are ready for consumption.

Hopefully, this primer gets you to look at Silverlight more closely.