How can you implement the Silverlight 3 Out Of Browser feature?

Kunal2383
Posted by in Silverlight category on for Beginner level | Views : 7339 red flag

Silverlight 3 came up with Out Of Browser support. Using that feature one can install the application just like a standalone windows application. Hence no need to open the browser to run the Silverlight application. Today for the first time I gone thru the APIs & created a sample application. Here I will discuss about the same to give you a demonstration.
Introduction
Silverlight 3 came up with Out Of Browser support. Using that feature one can install the application just like a standalone windows application. Hence no need to open the browser to run the Silverlight application. Today for the first time I gone thru the APIs & created a sample application. Here I will discuss about the same to give you a demonstration. It is quite easy to implement.
Code Steps

Create a Silverlight application using Visual Studio 2008. This will automatically create “MainPage.xaml”. Now open the MainPage.xaml & add the following lines inside the LayoutRoot Grid:

<StackPanel Margin="20" HorizontalAlignment="Center">
<
TextBlock Text="Silverlight Out Of Browser Demo Application" FontSize="20" HorizontalAlignment="Center"/>
<
Button x:Name="btnInstall" Content="Install as Out Of Browser Application" Width="300" Height="20" Margin="20"/>
</StackPanel>

Run your application to check whether your Silverlight application is working or not. Now if you click on the button, there will be no effect as we didn’t write the code for it. Hence go for it. Open the code behind file “MainPage.xaml.cs” and register the button event. Inside the button event write the below code:

App.Current.Install();

Run your application & click the Install button. You will come across Catastrophic Failure exception. Yes, right. This is because you didn’t mark the application as Out of Browser application. You have to explicitly tell it to be installed as out of browser. To do this, right click on your Silverlight project & go to properties. Enable the check box titled “Enable running application out of browser”.

image


Click on the button named “Out-of-Browser Settings…”. Here you can provide the title, size & icon for the install application. Now run your Silverlight application & right click on the page. You will find a new menu coming on the Silverlight context menu to install it as OOB (Out-Of-Browser). You can use the same menu item to install it. This will do the steps automatically. This comes automatically if your application supports the same. Here, we wrote our own code, so that, if we click on the button it will install. Hence, click on the button. This will show you a popup to install the application in your PC. If you go ahead this will install it on desktop & start menu. If successfully installed it will open the same as a standalone application. Close everything & go to the desktop. Open the installed application from the shortcut it generated. You will find that exact application is now available as a desktop application.


Page copy protected against web site content infringement by Copyscape

About the Author

Kunal2383
Full Name: Kunal Chowdhury
Member Level:
Member Status: Member
Member Since: 3/1/2010 12:38:55 PM
Country: India
Thanks & Regards, Kunal Chowdhury | http://www.kunal-chowdhury.com | http://twitter.com/kunal2383
http://www.kunal-chowdhury.com
He is currently working as a Silverlight application developer. Has a very good skill over C#, XAML, Silverlight & WPF. He has a good working experience in Windows 7 application (including Multitouch) development. During his professional career he worked in various technologies & delivered quality output. He never hesitates to take up challenges & work on the latest technologies in Microsoft platform. He attended various software development competition & achieved different awards. He is presently focusing on the RIA (Silverlight & WPF) & willing to become a Technology Specialist in Microsoft platform. Learning newer things, Blog posting & helping others in forums is one of his regular activity. Specialties: Silverlight Application Development, WPF Application Development, Windows 7 Application Development

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)