Even a chimp can write code

Monday, March 10, 2008

Silverlight 2: Application model

The first public beta of Silverlight 2 is now live. If you've played with building apps on it, you know we weren't kidding when we used the "Windows Presentation Foundation / Everywhere" moniker. Although we didn't inflict that monstrosity of a name on you, we did bring much of the sheer goodness of WPF in the APIs, the depth of functionality, the extensibility points and the overall experience designing or developing one of these babies.

In this first installment of a series of posts on Silverlight 2 features, I'll talk about the new Application Model. I'll loosely define an Application Model as "the principles on what constitutes an application, how it's lifetime is governed, and the set of services offered by a platform or runtime to the application". The Silverlight 2 Application Model borrows heavily from that of WPF. And it's goals are to be simple and predictable, to provide extensibility hooks, and otherwise to stay out of the way.

The Silverlight 2 application
The Silverlight 2 application is a client-side entity running within the confines of a host such as a browser. It is a packaged archive -- we use the Zip data compression and archival format -- with the .xap file extension and application/x-silverlight-app MIME type. Despite the introduction of this new application file, the Silverlight 2 runtime continues to support vanilla XAML content specified via file Uri or inline reference to SCRIPT block a la the v1.0 programming model.

Here's an outline of the features supported in the new application model:

  • New application package unit
  • Encapsulation of application functionality in a type deriving from System.Windows.Application, along with app definition XAML
  • Application lifetime: ctor, Startup event, Exit event
  • Handle exception conditions in a central location at the app level
  • Support for declarative dependency downloads, as well as programmatic for more granular control
  • Utility methods to extract app resources or resources from arbitrary Zip packages
  • Access to the Silverlight plug-in's object model via the Host property
  • Default splash screen provided by the platform, with ability to override it using custom XAML and JavaScript
  • Support for activating a Silverlight application from cross-domain (x-domain) to HTML page; secure by default, and ingress/egress need to be opted into.
  • Ability to refactor application functionality into individual pieces, daisy-chained together and dynamically loaded at runtime

A more detailed overview of the new Silverlight 2 application model is provided in this slide deck I've posted on my sky drive. The Silverlight 2 application model documentation on MSDN is a must-read. As always, feedback is appreciated. You can drop a comment here or post on the Silverlight forums.

Labels: ,

Email this | Bookmark this

2 Comments:

  • Hi;

    Could you please give us some guidelines for creating a solution or application that may have many pages/forms that a similar WPF or WinForm application may have?
    a) How to break down the app into multi pages.
    b) How can we Instantiate only the page that needs to be viewed and then release the memory when not in use?
    c) Should we load all the pages up front or should we load each page as needed (sample code would be great)?
    d) How do we pass data among these pages?

    I still have not seen one doc that lays out the formation of an app with many pages and how they should work in SL 2.

    Thank you and I hope I get some answers this time ;-)
    ..Ben

    By Anonymous Anonymous, at March 10, 2008 at 9:47 AM  

  • There's several good questions there. I'll respond with a post, rather than a comment. Queued one now.

    By Blogger Ashish Shetty, at March 10, 2008 at 5:39 PM  

Post a Comment | Home | Inference: my personal blog