Archive | August, 2011

Update XAP file

27 Aug

Installing and running a Silverlight application out-of-browser makes it possible to create a better experience to the user. Sometimes it is necessary to update the installed application and with the build-in functionality in Silverlight it is a pretty straight forward operation.

Depending on your application the update should be done early on in the application. Normally I do it as part of the Application Startup event before setting the RootVisual.

First we need to make sure the update is only done if the user is actually running the application out-of-browser. Application.Current.IsRunningOutOfBrowser will be true if the user has installed the application and running it out-of-browser.

2011-08-27_094955

On the Application.Current object we can call the CheckAndDownloadUpdateAsync method. This will check if an update is available and download it. The method is an asynchronous method and we need to subscribe on its complete event to complete the update.

If an update is available (and have been downloaded) the UpdateAvailable property of event arguments for the complete event will be true. The update (the new XAP file) have been downloaded but not installed as it is not possible to remove the old XAP file since the user is actually using it to run the application. Therefore the user need to restart the application to install the update.

2011-08-27_100104

In some applications it is ok not to require the user to restart the application but in most scenarios it is the preferred solution – think about service updates and so on.

At the moment it is not possible to separate the check and download. It is not possible to check if an update is available and the ask the user if she wish to actually download the update. If the CheckAndDownloadUpdateAsync method is called both check and download will be invoked.

In most debug scenarios this update check will be annoying since the XAP file will be updated everytime you build your project. To overcome this I normally adds an if-not-debug (#if !DEBUG) around the update check.

Source code is available here.

by xamlgeek

Slides and demos from WP7 talk

25 Aug

Earlier today I did a one hour talk about Windows Phone 7 and Mango. Most of the talk was about the platform but luckily I managed to show a demo based on a OData feed from Netflix.

The slides are available here and the demo is available here.

by xamlgeek

Articles about touch for Silverlight

2 Aug

This blog post contain some of the articles and projects I have read and used as part of a touch project for Silverlight.

Please let me know if you have read a good article about touch for Silverlight.

by xamlgeek

Follow

Get every new post delivered to your Inbox.

Join 1,356 other followers