20 December, 2010

WP7: How to programmatically modify menubar buttons

An unexpected caveat is found when attempting to modify the menubar buttons (enable/disable) on a WP7 application.

You can not (as you rightfully would expect) just reference the menubar buttons by name (x:name), and then access this in code. Due to reasons unknown to me, the menubar buttons are only accessible by index.


Due to this reason – you access (and manipulate) the button via ApplicationBar.Button[index] instead. In the below code sample, the ApplicationBarIconButton is retrieved via index and referenced as ‘b'.

void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
var b = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; //indx based!
b.IsEnabled = (pivItms.SelectedIndex == 1);

Technorati Tags:

08 December, 2010

WP7: I can only deploy 1 application/time to my phone ?

I today solved the mystery!

For a long time, it has appeared as if when I deployed a newly built application from VS2010, it somehow erased a (any!) previous application that I installed the same way. It was pretty consistent – only 1 application at the time it seemed! Come on – what’s that about?

The reason (as I learned), is that each application carries a unique ProductID (see below), which uniquely identifies the application to the phone. As Visual Studio does not generate a new unique ID on launch when you go “File – New…”; I was effectively reusing the same ProductID and replacing the existing (old) application on the phone.

How to solve this?
1) Open Guid Generator
2) Create a new GUID (Registry style)
3) Replace the exiting default ProductID with the newly generated version (2)
4) Build
4) You are good to go!


Technorati Tags: ,

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...