Roger's Blog | Well, I think it's interesting.

Archive for October 2010



MS to WP7 Devs: “No Soup for You!”


So it turns out that Windows Phone 7 does support multitasking and does support SQL CE. It’s just that you can’t have it because Microsoft doesn’t want you writing shitty apps that show their phone in a poor light (at least that’s the “not-quite-so-between-the-lines” take-away from today’s New York City launch event.)

Funny thing about my Android phone. It ran like crap with lousy battery life until I rooted it and removed the junk Sprint pre-loaded on it. We’re about two weeks away from GA of Windows Phone 7 and all the demos are still pre-production units. It will be interesting to see how much stuff AT&T and T-Mobile preload on these phones (that you, of course, cannot remove.)

No tags



WP7 Headscratcher

I’ve been exploring the Windows Phone 7 SDK in preparation for a launch event in New York next week by porting the CodeStock Android application to WP7 and I’ve run into a bit of a headscratcher.

The Android app uses a context menu option to permit the user to refresh the data from the website “on-demand” so I created an ApplicationBarIconButton (named “downloadScheduleButton” surprisingly enough) for the same functionality. On first test the app crashed with a null object reference on the line in the main page’s constructor added to wire-up the click handler. The line of code looks like this:

this.downloadScheduleButton.Click += new EventHandler(downloadScheduleButton_Click);

The null reference was “downloadScheduleButton” and yes, I did put the line after the call to InitializeComponent(). The generated SilverLight code for the page included this line in InitializeComponent:

this.downloadScheduleButton = ((Microsoft.Phone.Shell.ApplicationBarIconButton)(this


but FindName was returning null. The docs for FindName included this note:

"A run-time API such as FindName is working against an object tree. These objects are loaded into the content area and the CLR runtime engine of the overall Silverlight plug-in. When part of the object tree is created from templates or run-time loaded XAML, a XAML namescope is typically not contiguous with the entirety of that object tree. The result is that there might be a named object in the object tree that a given FindName call cannot find."

The docs continue by discussing using  GetTemplateChild, VisualTreeHelper, or XamlReader.Load but none of the cases seem to apply here. Further, the ApplicationBarIconButton class doesn’t expose a Name property so I can’t write my own method to loop through buttons and matching by name.

I got around it by using

((ApplicationBarIconButton)this.ApplicationBar.Buttons[0]).Click += new


but that’s awfully fragile and will break if the order of buttons is rearranged. What am I missing here?

No tags


Had a great time this past weekend in Richmond, VA for Richmond CodeCamp X. Had a good turnout at a great venue and while my session was rather sparsely attended we had some good discussions and questions.

As promised here is the slide deck and the sample apps. The ZIP file does not include the Restlet and ksoap2-android libraries (because my web host limits upload sizes) but you can download Restlet from There has been a revision to the Restlet library (from v 2.0.0 to 2.0.1) but I’ve tested the sample application to make sure it works with 2.0.1. There have also been changes to the ksoap2-android library in that the dormant 2.4 fork has been taken over by Manfred Moser, who had created the original 2.5 fork. The 2.5 fork (which is the one my demo used) is gone and only the 2.4 fork is available. The 2.4 fork can be downloaded here. The Eclipse folder is meant to be the root of an Eclipse workspace so I didn’t include the .metadata folder.

Inside the folders for the two Eclipse projects there are “libs” folders that are placeholders for the Restlet and the ksoap2-android libraries; you will probably have to fix-up the classpath for both projects. The Visual Studio project is meant for Visual Studio 2010 Professional or higher.

Android and .NET Services Presentation

No tags

Theme Design by