Windows Phone 8 Dev – Localizing the AppBar


In my previous post I looked at the basics of app localization (supporting other languages). If you are not familiar with setting up the Name and Value pairs in the AppResources.resx files then you will need to refer to that post before proceeding.

Before I looked at localizing my app I had my App Bar setup on my MainPage.xaml like this:

        <shell:ApplicationBar Mode="Minimized"

            <shell:ApplicationBarIconButton Click="about_Click"
                                            Text="about" />

As I could not find a solution for binding to my XAML appbar I decided to do it in C# instead. So I commented out my XAML App Bar (MainPage.xaml) and the Click event in MainPage.xaml.cs.

This is my App Bar setup in MainPage.xaml.cs:

public MainPage()

                // Set the page's ApplicationBar to a new instance of ApplicationBar.
                ApplicationBar = new ApplicationBar();
                ApplicationBar.Mode = ApplicationBarMode.Minimized;
                ApplicationBar.Opacity = 1.0;
                ApplicationBar.IsVisible = true;
                ApplicationBar.IsMenuEnabled = true;

                // Create a new button and set the text value to the localized string from AppResources.
                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/Images/", UriKind.Relative));
                appBarButton.Text = AppResources.AppBarButtonText;
                appBarButton.Click += new EventHandler(appBarButton_Click);

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


As you can see the App Bar Button has a binding to AppBarButtonText (which is defined in my AppResouces.resx files).

Here is the Click event for the button:

        private void appBarButton_Click(object sender, EventArgs e)
            NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative));

And there is my localized App Bar button.

about spanish

Happy coding!


One thought on “Windows Phone 8 Dev – Localizing the AppBar

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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