Localizing Windows Phone App Bar

In the previous post, we talked about how to localize your windows phone application, which will grant you a double potential for it.

In this post, we will specifically state how to localize the app bar.

Adding an app bar, at the first place, could be done in two ways.

  1. adding it in the XAML page
  2. using C# in the page code-behind. However

But in spite of that; the XAML app bar doesn’t support dynamic data binding for the text label of the ApplicationBarIconButton or for the ApplicationBarMenuItem.

For this reason, the following code, along with calling it in the MainPage constructor and placeholder resources, are reproduced as commented samples in each relevant New Project template.

// Build a localized ApplicationBar
private void BuildLocalizedApplicationBar()
    // Set the page's ApplicationBar to
    //a new instance of ApplicationBar.
    ApplicationBar = new ApplicationBar();

    // Create a new button and set the text
    //value to the localized string from AppResources.
    ApplicationBarIconButton appBarButton =
        new ApplicationBarIconButton(new
        Uri("/Assets/AppBar/appbar.png", UriKind.Relative));
        appBarButton.Text = AppResources.AppBarButtonText;

    // Create a new menu item with the
    // localized string from AppResources.
    ApplicationBarMenuItem appBarMenuItem =
        new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);

This was simply how to localize the Application bar
For any feedback or questions, you’re more than welcome to send me an email atyasmine.abdelhady@hotmail.com or reach me @yasabdelhady on twitter.


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s