Migrating to Mango – Developer View. Part 1

Below I’ll be talking about my experiences I made when migrating to Mango, more specifically to its Beta 2 release. Note that I won’t be talking about Mango features, but rather about the problems I encountered when I was migrating to Mango. I’ll also try to look behind the scenes so that the readers better understand the differences between different WP7 versions.

Windows Phone 7 is one of Resco’s core platforms and we offer there a control library – Resco.Controls. Our users started asking if the library is Mango-compatible. In two cases I got even signals that AdvancedList control might have problems. Ok, as the developer interest in Mango clearly growths, we had no choice but to join.

Installation

Of course, we have to start with the installation, which encompasses

a) Visual Studio 2010 SP1 (if you haven’t done it already – see the VS About dialog)

b) Windows Phone SDK 7.1 (Beta 2)

Installation was long (due to web downloads), but straightforward. When done, I opened an existing project and looked around what has changed. Seemingly nothing, but when I looked into the project properties I found new option – Target Windows Phone version that lets you select either WP7.0 or WP7.1. Ok, that seems to be the thing that should be tested first.

Project preferences let you select phone version

Testing existing projects

I tested altogether 8 non-trivial apps, i.e. all basic Silverlight controls as well as all custom controls from Resco.Controls library. The code used a lot of binding and templating, dynamic control construction, animations etc. Perhaps the only important controls not tested were Pivot and Panorama – maybe next time.

Every project was tested in two steps:

– Simple recompilation of the old project and running it on the a) WP7.0 device, b) WP7.1 emulator.

– Modifying the project to target WP7.1 and testing it on the WP7.1 emulator.

Well, I denote the emulator as WP7.1, but this just means the emulator left after the installation. It looks like Mango emulator, but that’s all I can say right now.

Testing results

I have to say it was better than expected: One serious problem and another minor one. The first problem was this build error:

“MSBUILD : error : Xap packaging failed. Could not find file ‘…ApplicationIcon.png’.”

It turned out that I moved the png file to the Images subfolder, but did not update the WMAppManifest.xml file. Mango was less tolerant than the old SDK, in fact it correctly reported an existing bug.

The second problem was a lot worse. I used a ListBox-based class with custom ListBoxItem. It appeared to crash in the layout phase with a nonsense error. (Non-specific error with zero information attached.) Simply a situation where you don’t know what to do. After poking around and classifying every available info as useless I decided for brute-force attack: Simplify, simplify, simplify…

It might have taken a dozen of iterations and elimination of 95% of the code until I found that Mango does not like this construction (used within ListBoxItem template):

<ControlTemplate> <ContentPresenter Content=”{TemplateBinding Content}”/> </ControlTemplate>

Once I realized that ContentPresenter implicitly binds Content if used within the ControlTemplate, I removed TemplateBinding and everything worked (even in WP7.0 case):

<ControlTemplate> <ContentPresenter/> </ControlTemplate>

(The template is a bit simplified, but you get the idea.)

Advanced list with problematic item template

Next parts will come soon

 

About the author

Jan Slodicka

Programming for over 30 years. Covered several desktop platforms and programming languages. Since 2003 working for Resco on mobile technologies – Palm OS, Windows Mobile, Windows Phone 7, Android. You can contact me at jano (at) resco (dot) net.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s