Silverlight Sample Application – Part 2

In this series blog post I’m continuing to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The first ‘page’ of the application shows the event website.

20100613 home

To do this, our page simply includes the web browser control in the XAML…

20100613 webbrowser

and a bit of code in the code-behind class also inheriting from the provided Page class constructor.

20100613 webbrowser 2

Simple enough right?


This code will fail when you try to debug/launch the application in a web browser.  The web browser control requires the application to be installed out-of-browser by the user and with elevated full trust.

20100613 oob

In the project properties, running Out-of-Browser needs to be enabled, the settings configured and the “Require elevated trust when running outside the browser” needs to be checked.

So HTML content and be hosted alongside the Silverlight control in a web page, but to host HTML content inside the Silverlight control you need the user to agree to the elevated trust and run the application outside of the browser.

To avoid making this page useless when the application is run inside the web browser, code was added as follows:

20100613 oob detect

This code detects if the code is running out of browser or not.  If it’s in-browser then the browser control is hidden, and a hyperlink control added to the main grid allowing the user to click it and be taken to a web page using their default web browser.

Be sure to check out the other features a Silverlight 4 application can use if it runs out of browser.

Check out other series blog posts for more information about this sample application.