Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Up until very recently, there were two models for building applications. The desktop model is a familiar one: recreate an application that runs on Windows or the Mac OS. This application is installed locally and can exploit the rich services offered by the operating system. Then there is the web model. This model has rocketed to the top of the food chain in the last 10 years. Web apps are launched from the browser, run within the browser window, and are often limited in what they can do with the local computer. But more and more, we are seeing a blurring of the lines in web applications.
Adobe AIR is an example of a technology that allows apps to run in or out of the browser. And now of course, Silverlight supports the idea of an out-of- browser application. This is often referred to as an OOB app. So what are the benefits of using OOB? First, the application runs in its own window, not a browser window. And in Silverlight it is hosted in a process called SL Launcher. As you might guess from the name, an OOB application does not require an Internet connection.
The app launches locally and runs like any other local application. The application is automatically updatable, however. If an Internet connection is available, then the application checks with the server to see if the new version is available. If so, the new version is always automatically downloaded. The next time you run that application, it uses the new version. It's time to show you how to create your own out-of-browser Silverlight application. As you can see, I have Visual Studio 2010 opened on my desktop, and I have opened this project called CreatingOobApp.
When I run this application by pressing F5, it will launch a browser window and load my Silverlight application in that browser window. When I right-click on this, you will see a context menu that says Silverlight. This is not yet an OOB application. When I return back to Visual Studio, all I need to do to convert this to an OOB application is double-click on the Properties node in the Solution Explorer and then choose Enable running application out of the browser.
Now when I run the application, I no longer see a browser window and when I right-click on the application, I see a Remove this application. Now that seems odd that I see that Remove this application, but that's because the default setting in Visual Studio is to automatically install the application when I debug it. If I would rather see the install menu, I need to go back to Visual Studio, choose Debug, and uncheck this Out-of- browser application and instead choose Dynamically generate a test page.
Now let's run the application again to see what it looks like. It looks the same. If I right- click, I now see Install Creating OOB Application onto this computer. When you choose this option, you are asked if you'd like a shortcut on your Start menu and your Desktop. I think that's a great idea, so I'm going to choose both and then click OK. Now the application is running out of browser, and I also have, in my Start menu, a new shortcut for creating the OOB application.
If I click on this shortcut, it launches another instance of my out-of-browser application. So now I have two versions of the out-of-browser and one running inside my Firefox browser. When your user tires of your application, all they need to do is right-click and choose Remove this application. Now all traces of that application are gone from this machine. Alternatively, you can go to your Control panel, usually in the Programs and Features section, and choose to uninstall from there.
For more control over my application, what I can do is go into my Properties window, choose Silverlight, and then go into this Out-of-Browser Settings. Here I can change what the text is actually shown on the shortcut. Also, you might want to control how the user installs. Rather than having the user right- click, maybe you would like to put your own Install button in your application. Let me show you how to do that. I'm going to open this file called CheckOob.xaml.
And then I'm going to make it my start page by going to my App.xaml.cs file, double-click, and I'm going to edit line 29 here where it says I want to instantiate the MainPage. Now I want to instantiate the CheckOob page. Press F5 to run the application and here is our start page. Notice that it says, Is Network Available, is true. The Internet is available. And I am currently running this in the browser.
When I click on this button, I see the same install dialog we saw a few minutes ago, and now take a look at the difference in these screens. This says the Internet is available and it also says the app is running out of browser. So we can detect not only is the Internet connection available, but is the application running in or out of the browser? Let me show you how the code does that. Switching back to Visual Studio, opening up my CheckOob.xaml.cs file by double-clicking. And the installation code is simple.
It's one line of code down here at the bottom, Application.Current.Install. That's how simple it is to install an out-of-browser application. It's almost as simple to find out if the network is available. There is a function called GetIsNetworkAvailable, which I can call to find out if I'm on the Internet. This is important because if you are trying to call a service on the web, say to download a music file, you need to know if you're running out of browser and if the network is available for you to do that call.
I can also find out if I'm in the browser by checking this Boolean property, IsRunningOutOfBrowser. So what I shown you so far is how to create a basic out-of-browser application. In other movies in this chapter, you will learn more about configuring these kinds of applications.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98508 Viewers
61 Video lessons · 85800 Viewers
71 Video lessons · 69704 Viewers
56 Video lessons · 102010 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Your file was successfully uploaded.