johnvisiomvp

Life with Visio and other Microsoft Toys!

WP7 – Raising the Bar

leave a comment »

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

Advertisements

Written by johnvisiomvp

April 20, 2013 at 2:41 pm

Posted in Windows Phone 7, WP7

Tagged with ,

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

%d bloggers like this: