This is a mirror of official site: http://jasper-net.blogspot.com/

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

| Sunday, March 7, 2010
  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”.

Read more: .Net Funda

Posted via email from jasper22's posterous

0 comments: