Monday, July 20, 2009

Silverlight 3 Out of Browser Quicky

One would think that being on the silverlight insiders list and being a silverlight mvp etc one would know when something changes but amoung all the meetings, and conferences and the like I missed a tiny change in the Silverlight OOB - from the initial beta and the release of Silverlight 3. That weekend that the release happened I went to go and upgrade all my projects to the latest bits and everything feel a part. I found when I removed all the out of browser stuff it all seemed fine. it didn't take long to realize the API's changed but took me a whole fraking (BSG lingo) week before I realized what happened to editing the application manifest. That being all the case let me recap how to build an OOB Silverlight 3 application.

Step 1, build a Silverlight application of some kind.

Step 2, right click on the properties of your Silverlight Project (the actual app project not a class library or something). Normally you should get the Silverlight tab of the properties pain.

Step 3, 'Click' the check box for 'Enable running application out of the browser.'

Optional step 4 would be to click the 'Out-of-Browser' Settings button and then to set icons and details as desired.

Optional Step 5 would be to customize the UI with an install button. In the case of Simon, in the page constructor that is using the Simon control we add some code like this to see if we should show the install button:


if (Application.Current.InstallState == InstallState.Installed)
{
installbutton.Visibility = Visibility.Collapsed;
}

then in the install Simon button event handler we use this line to trigger an install

Application.Current.Install();

from there you can pretty much do what ever you like. its easy simple and better then editing the raw manifest like we did with the beta, but to be honest I kind of like raw XML... Now those settings are not in the manifest but a seperate file called 'OutOfBrowserSettings.xml' which seems to contain everything that was in the manifest.

No comments:

Post a Comment