(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Silverlight as a Desktop Application (Out-of-Browser Applications)

(11 votes)
Nikolay Raychev
>
Nikolay Raychev
Joined Mar 28, 2008
Articles:   22
Comments:   58
More Articles
17 comments   /   posted on Mar 18, 2009
Categories:   Line-of-Business , Out-of-Browser

This article is compatible with the latest version of Silverlight.

Introduction

A cool new feature in Silverlight is the ability to run Silverlight applications out of the browser which resembles a desktop application. Only a few configuration steps are needed to enable your application to run offline.

See also:
Tip: Detecting Network Change in Silverllight 3 Application

Overview

To enable this feature you only need to open the AppManifest.xml file which can be found in the Properties folder and add
some settings as follows:

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  EntryPointAssembly="TaskList" 
  EntryPointType="TaskList.App">  
  <Deployment.Parts> 
  </Deployment.Parts> 
  <Deployment.OutOfBrowserSettings> 
    <OutOfBrowserSettings  
      ShortName="Task List">  
      <OutOfBrowserSettings.WindowSettings> 
        <WindowSettings Title="Offline Task List" /> 
      </OutOfBrowserSettings.WindowSettings> 
      <OutOfBrowserSettings.Blurb> 
        Allows saving your tasks offline  
      </OutOfBrowserSettings.Blurb> 
    </OutOfBrowserSettings> 
  </Deployment.OutOfBrowserSettings> 
</Deployment> 
 

Provided that your application is called TaskList you must add two attributes to the Deployment element:

  • EntryPointAssembly="TaskList"
  • EntryPointType="TaskList.App"

You must also add the OutOfBrowserSettings section with the following settings:

  • ShortName - the name of the application displayed on the desktop or the start menu.
  • Title - the title displayed in the title bar of the window which runs the application.
  • Blurb - this is seen in the "Comments" section of the file.

You are done. When you run your application in the browser you can notice the following context menu:



Note that if your application is not configured for offline use the "Install ... onto this computer..." is disabled and since we've configured it we can click it and the following dialog appears:



You have the option to choose where to put shortcuts to your application. By clicking "OK" you are ready and your Silverlight application is added as a standalone application.

Removing the application is as easy as adding it. When your application is saved for offline use the context menu looks as follows:



Clicking "Remove this application" and confirming removes the application from wherever it is added and also removes the shortcuts.

You also have the option to put your own icons which will be used by your application as a desktop icon, icon in the start menu, etc. You just need to create 4 png files with sizes 16x16, 32x32, 48x48 and 128x128. Include them in your project and set their Build Action to Content. It's easy, just right click on the image in the Solution Explorer and go to Properties. After that you must specify paths to the icons in the OutOfBrowserSettings section as follows:

<OutOfBrowserSettings.Icons> 
  <Icon Size="16,16">Images/sls16.png</Icon> 
  <Icon Size="32,32">Images/sls32.png</Icon> 
  <Icon Size="48,48">Images/sls64.png</Icon> 
  <Icon Size="128,128">Images/sls128.png</Icon> 
</OutOfBrowserSettings.Icons> 

That's all. You have your custom icons.

Now the whole AppManifest.xml file looks like:

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  EntryPointAssembly="TaskList" 
  EntryPointType="TaskList.App">  
  <Deployment.Parts> 
  </Deployment.Parts> 
  <Deployment.OutOfBrowserSettings> 
    <OutOfBrowserSettings  
      ShortName="Task List">  
      <OutOfBrowserSettings.WindowSettings> 
        <WindowSettings Title="Offline Task List" /> 
      </OutOfBrowserSettings.WindowSettings> 
      <OutOfBrowserSettings.Blurb> 
        Allows saving your tasks offline  
      </OutOfBrowserSettings.Blurb> 
      <OutOfBrowserSettings.Icons> 
        <Icon Size="16,16">Images/sls16.png</Icon> 
        <Icon Size="32,32">Images/sls32.png</Icon> 
        <Icon Size="48,48">Images/sls64.png</Icon> 
        <Icon Size="128,128">Images/sls128.png</Icon> 
      </OutOfBrowserSettings.Icons> 
    </OutOfBrowserSettings> 
  </Deployment.OutOfBrowserSettings> 
</Deployment> 

The application updates automatically whenever you release a new version on the server. When you start the offline version or it detects that the network is present it checks for a new version, downloads it and updates itself. Whenever you start it again you will be using the updated version.

Demo

As an example I created the following demo:


This is a simple tasks list. You can add or delete tasks. The tasks are saved on the server and the application is using WCF Service to connect to the server. Nothing special. But if you save the application for offline use you can use it even if you don't have internet connection. I'm using the isolated storage to keep copy of the data on the client and the application is working with the local copy when there is no connection. It synchronizes automatically whenever the connection comes back.

Download Source 

Conclusion

This article describes the steps you need to make in order to allow the users to make your Silverlight application act like a Desktop application on their computers. Any comments are welcome.


Subscribe

Comments

  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Zeze Lazo (zezelazo@msn.com) on Mar 19, 2009 07:24
    I cant install the app, the menu item is disabled, i need something more, i have the beta 3 developer runtime
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Zeze Lazo (zezelazo@msn.com) on Mar 19, 2009 07:28
    I solveit :p the menu item is enables only at the first page (with button [Show Task]), in the next page the link is disabled
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Hunsoul on Jul 13, 2009 16:29
    The download link is dead...could you check it please?
  • nikolayraychev

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by nikolayraychev on Jul 15, 2009 11:19
    Hunsoul, the source is available now and is converted to Silverlight 3 RTW.
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by vijay on Aug 18, 2009 15:45
    cool :-) really nice, simple & useful article.

    Vijay


  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Alexo on Sep 23, 2009 22:53
    Thx man, is very usefull !!!!!! like it
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Dave on Sep 25, 2009 15:09
    Excellent, thanks for this
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by okyanus on Sep 28, 2009 13:20
    super
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Thomas on Oct 30, 2009 12:28
    The VS tool for SL 3 now have an option to create the OOB settings for you.  Double click the project file  Select Enable running application out of browser and then hit the Out of Browser Settings button and youre done.
  • nikolayraychev

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by nikolayraychev on Nov 10, 2009 15:19
    Thanks for the useful info, Thomas.
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by UYGUR on Nov 24, 2009 14:43
    Thanks!
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Marco on Feb 19, 2010 12:54
    Very useful, cheers !!
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Christine on Mar 03, 2010 18:39

    Great!

    Thanks a lot :)

  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Roger on Mar 18, 2010 12:56
    Thumbs Up!
  • -_-

    RE: Silverlight 3 as a Desktop Application (Out-of-Browser Applications)


    posted by Gaurav bhardwaj on Jun 11, 2010 07:13
    Can be pass the WCF data on the  out of browser applications when this connection will be established with the server and how Out Of Browser application will come to know that  this is the connection that it has to be established with WCF client
    .
  • -_-

    RE: Silverlight as a Desktop Application (Out-of-Browser Applications)


    posted by Harish on 09:50
    Nice !!
  • AmanChawla

    Re: Silverlight as a Desktop Application (Out-of-Browser Applications)


    posted by AmanChawla on May 21, 2012 11:03

    Viewing as a desktop application

    It can be done in this way...

    http://amtdw.blogspot.in/2012/05/techie.html

    But what's the difference???

     

Add Comment

Login to comment:
  *      *