WP7 – Raising the Bar

The Application Bar is more than four static buttons. It can be dynamic. Initially I tried to change the visibility of the buttons, but that was not an option. The best I could do within XAML was to disable a button. The methods I have seen seem to involve creating a button in XAML and then do a RemoveAt if the button is noin code t needed.  The next issue was trying to support multiple languages. Using Binding does not appear to work. So to support multiple languages code behind was needed to do the binding.

So given these limitations, how can you make the process tolerable? The strategy appears to be to limit the amount of work done by XAML and use code beyond to determine if a button should be added rather than trying to remove it.

   var button = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
   button.Text = AppResources.lblChallenge;
   button = (ApplicationBarIconButton)ApplicationBar.Buttons[1];
   button.Text = AppResources.lblLdrBoard;
   button = (ApplicationBarIconButton)ApplicationBar.Buttons[2];
   button.Text = AppResources.lblHelp;

   // and now for the AppBar menus
   var menuitem = (ApplicationBarMenuItem)ApplicationBar.MenuItems[0];
   menuitem.Text = AppResources.lblOptions;
   menuitem = (ApplicationBarMenuItem)ApplicationBar.MenuItems[1];
   menuitem.Text = AppResources.lblNewEvent;

Depending on the name you use for the app, you may want to customize the tiles. Peter Tihanyi has a good explanation here http://engine-designs.com/wp7-appreslib-dll-generator.html .

Hopefully this has revealed some of the secrets behind the Magic Happens part of adding languages to a WP7 app. This is a work in progress and I will be adding to it as I continue to implement the languages.

Update: The current method for creating an AppBar is to do it all in code behind.

John Marshall… Visio MVP       Visio.MVPs.org

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993