Published: 07 Jul 2010
By: Manning Publications

This article is taken from the book Silverlight in Action, Revised Edition. The author discusses out-of-browser (OOB) applications, which provide the best of Silverlight's cross-platform support along with a locally installed and offline enabled experience.

Contents [hide]



About the book

This is the 5th chapter of the book Silverlight in Action, Revised Edition. It has been published with the exclusive permission of Manning.


Written by: Pete Brown
Pages: 425
Publisher: Manning
ISBN-10: 9781935182375
Get 30% discount

DotNetSlacker readers can get 30% off the full print book or ebook at www.manning.com using the promo code dns30 at checkout.

One of the most exciting new features introduced with Silverlight 3 and enhanced in Silverlight 4 is support for out-of-browser (OOB) applications. OOB applications give us the best of Silverlight's cross-platform support along with a locally installed and offline enabled experience.

OOB Silverlight applications aren't hosted in a real browser instance—at least not in the way we would typically think of a browser—and, therefore, they don't have access to the HTML Document Object Model (DOM). Instead, the applications must be full-page, self-contained applications, without reliance on HTML, JavaScript, or other in-page assets.

Silverlight OOB applications are already seeing significant uptake within corporations behind the firewall due to their simple installation, update models, and presentation and data manipulation capabilities.

OOB Silverlight applications look just like their full-page in-browser equivalents but without all of the extra browser chrome. A sample Silverlight OOB application may be seen in figure 1.

Figure 1: My first Silverlight out-of-browser application: a Commodore 64 emulator using the updated MediaStreamSource API.

The in-browser version is shown in figure 2.

Figure 2: The same Silverlight application running in the browser

Between the two screenshots you can see that the Silverlight portion of the experience remains identical (with the exception of the frame rate display I have turned on when in the browser). The code and .xap file is the same in both instances. What changes is how much chrome surrounds the application and how much real estate is made available to Silverlight rather than to browser functionality.

Silverlight provides APIs for detecting and responding to changes in network connectivity and for indentifying if the application is running in or out of the browser and if there are any updates available. All of these, combined with the rich set of capabilities provided by Silverlight make for a compelling OOB application platform.

Before deciding to create an OOB application, it's important to understand the capabilities and restrictions.

Capabilities and restrictions

The Silverlight out-of-browser applications work just like the Silverlight in-browser applications with some minor differences:

  • Isolated storage quota for out-of-browser applications is 25 MB by default, as opposed to 1 MB for in-browser applications. In both cases, this can be extended by prompting the user.
  • Out-of-browser applications provide access to the keys that the browser normally captures, such as function keys.
  • Out-of-browser applications can be pinned to the start menu or task bar in Windows systems and display custom icons but cannot otherwise integrate with the Windows 7 taskbar without using COM automation in Elevated Trust Mode.
Elevated Trust Mode

Elevated Trust Mode is one of the most exciting things to happen to out-of-browser applications. Now we have access to more local files and resources, fewer confirmation prompts, and a better integrated experience. On Windows, we also have all the power provided by COM automation. We get all this as the result of a single setting and user confirmation dialog; no messing around with browser settings or code access security.

Elevated trust mode even lets you control the out-of-browser window from simple sizing and location all the way through to creating your own custom window chrome—borders, title bars, buttons, and other elements that decorate a typical window on a given operating system.

Sometimes what you want is not a separate window but rather to take your in-browser or out-of-browser application and make it run full screen. Silverlight supports that as well, a killer feature for media players and kiosk applications. When run in Elevated Trust Mode, full-screen applications have even more capabilities.

  • Out-of-browser applications require an explicit check for a new version, whereas the in-browser versions automatically update.
  • Out-of-browser applications support Elevated Trust Mode.
  • Out-of-browser applications cannot receive initialization parameters or take advantage of any of the plug-in parameters while running out of browser.
  • Out-of-browser applications cannot interact with the HTML DOM; there is no DOM to work with.

If you want those capabilities and can live with those restrictions, an out-of-browser application may be for you. If you need more power and fewer restrictions, consider creating a click-once WPF application.

The end user experience for installing Silverlight applications is slightly more complex than just hitting a web page and running Silverlight content but not nearly as involved as a regular platform application (exe) install.

The end user experience

An end user visiting your site will see a typical Silverlight application. If the application is OOB-enabled, they'll be able to right-click on the surface to install it locally, assuming you've left that capability intact. In addition, you may provide them with a button on the screen to perform the installation without requiring the right-click. The default experience is shown in figure 3.

Figure 3: The install menu for an OOB-enabled application is accessed by right-clicking on the Silverlight surface.

The installation process is painless, being simply a copy of files to an obfuscated location on the local machine. There are no registry entries required, no additional platform DLLs, and no admin rights—nothing extra. As seen in figure 4, the user only has to choose where to put shortcuts (start menu and/or desktop) and decide whether to approve or cancel the install—a very low-friction experience compared to a typical platform application install.

Figure 4: The install dialog gives the user an option to place shortcuts on the start menu and on the desktop. The install icon on the left is customizable as is the application name.

Once the user takes the application out of the browser, the .xap will be re-requested from the server and stored in a low-trust location on the local machine along with the information about the xap’s original URI and download timestamp. It will then appear in the places the user selected (start menu and/or desktop) via the dialog in figure 4, and also on the taskbar. The user may, as with any other application, pin the shortcut to the start menu or (in Windows 7) to the taskbar.

The application will also immediately launch in the out-of-browser mode as seen in figure 5. At this point, the user may close the browser window.

Figure 5: The application running in the out-of-browser mode. Note that both the application window title and source domain (localhost in this case) are displayed in the title bar.

Figures 6 shows a Silverlight application (the Commodore 64 emulator) pinned to the start menu on a Windows 7 machine. Note the use of custom icons and information about the name of the application.

Figure 6: A Silverlight out-of-browser application with custom icons pinned to the start menu in Windows 7. The application below it, TweetDeck is an Adobe AIR application, another competing out-of-browser RIA technology.

Figure 7 shows the task bar.

Figure 7: The same Silverlight out-of-browser application pinned to the task bar in Windows 7

To uninstall the application, the user may right-click the Silverlight application and select the menu option Remove this application or use the control panel’s Add/Remove Programs applet. Again, no special rights are required and the process is painless.

As you can see, Silverlight OOB applications look and act very much like another desktop application, while providing a very simple installation experience for the end user. You get the local experience of a desktop application with the ease of deployment of a web application.

Summary

For a web technology, Silverlight provides an unprecedented level of desktop integration. With Silverlight 4, we now have the ability to run in-browser or out-of-browser in Partial Trust Mode or out-of-browser in Elevated Trust Mode. When running out-of-browser in partial trust, you gain additional storage capacity without prompting, additional keyboard information, and a reduction in host chrome that allows you to take greater advantage of screen real-estate and provide a truly custom experience. For many behind-the-firewall business applications and both custom experiences and self-contained internet-delivered applications, this is a compelling option with no real downside.

Get 30% discount

DotNetSlacker readers can get 30% off the full print book or ebook at www.manning.com using the promo code dns30 at checkout.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Manning Publications

Manning Publication publishes computer books for professionals--programmers, system administrators, designers, architects, managers and others. Our focus is on computing titles at professional levels. We care about the quality of our books. We work with our authors to coax out of them the best writi...

This author has published 33 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category


Displaying Notification Messages in a Silverlight Dashboard Application
In this article we will see how we could display a notification message and further a list of notifi...
Air Space Issue in Web Browser Control in Silverlight
Air Space issue is a common issue in Web Browser control in Silverlight and WPF. To explain the issu...
TextBox Row Filter in Telerik's RadGridView in Silverlight
If you have come across the JQGrid features, you might have seen the filter row available as the fir...
Widget Refresh Timer in MVVM in Silverlight
In this article we'll see how to refresh and disable widgets using the Model View View-Model pattern...
Develop a Flexible 2.5D Scene Editor Targeting Silverlight RPG Games - Part 2
In this article, I'm going to introduce to you how to construct such a 2.5D RPG game scene editor th...
Top
 
 
 

Please login to rate or to leave a comment.