Floating FB popout byF5debug

101 How to on Windows Phone – How to #51 – Globalize your Windows phone application


In this article we are going to see how we can globalize the application which we are developed with Windows phone (any version like 7, 7.5, 8 etc). Globalizing an application will be based on the requirement to show the data in a format or a way that is familiar to the end user. Say we have multiple languages and have multiple formats the data can be used and showed, we should write our application in a much easier way which takes less effort to show the application in different ways to the users. Let us take an example of a ecommerce application, if an end user is trying to access the application from India then it should show INR as the currency and a users opens the application from United States then it should be $ if the same user uses the application from other region the respective currency info should be loaded these problems can be achieved through using the Globalization in the application.     [more]

Let us see the steps on how to achieve this task in our Windows Phone application development. Open Visual Studio 2012 IDE and create a new Windows Phone project with a valid project name as shown in the screen below.   


Clicking on OK will create the project and the solution with the list of default files and folders that are required to run the application. It will take some time to create these files based on your system configuration, so once everything is ready we can see the Visual Studio IDE with the project as shown in the screen below.

XAML Code:


<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="F5debug How to Series" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Globalize App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Get data in Other Language" Height="72" HorizontalAlignment="Left" Margin="9,6,0,0" Name="button1" VerticalAlignment="Top" Width="441" />
            <TextBlock Height="277" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="29,108,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="407" />



Now add few controls which basically used to demonstrate how to Globalize the application. In real time we can use it while loading the application so that it reacts based on the location or market from which the application is downloaded and used. We need to use CultureInfo class to get information about a specific culture which includes the name of the culture, system information, calendar used and some of the formatting used for numbers, dates and strings. So instantiate the Culture info class and call the appropriate culture so that we will get the information in desired language as shown in the code below.

C# Code:


private void button1_Click(object sender, RoutedEventArgs e)
           string strCul = "fr-FR";
           CultureInfo newCulture = new CultureInfo(strCul);
           Thread.CurrentThread.CurrentCulture = newCulture;

           CultureInfo cc, cuic;
           cc = Thread.CurrentThread.CurrentCulture;
           cuic = Thread.CurrentThread.CurrentUICulture;

           txtRegFormat.Text = cc.NativeName;
           txtLanguage.Text = cuic.DisplayName;

           DateTime curDate = DateTime.Now;
           txtDate.Text = cc.DateTimeFormat.LongDatePattern.ToString() + " " + curDate.ToString("D");

           txtTime.Text = cc.DateTimeFormat.LongTimePattern + "   " + curDate.ToString("T");

           Int64 money = 1000300;
           txtMoney.Text = money.ToString("C");


Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.


About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter