Question

is it possible to get list of country names and country codes somehow from phone? E.g. the list of countries is displayed in Settings.

Or can I easily get country name from country code like gb,de,fr,cs,...

Thank you

Was it helpful?

Solution

Because of absence of some functions in silverlight version of CultureInfo and RegionInfo I decided to use resource file with international code and international country name.

The list of countries is provided here: https://gist.github.com/901679

I really don't know why silverlight version doesn't support same functions like .NET version of Culture/RegionInfo.

OTHER TIPS

I dont think you can get the cultures in code, but here is a list of Accepted Cultures

  • USA, English, en-US
  • UK, English, en-GB
  • Germany, German, de-DE
  • France, French, dr-DR
  • Spain, Spanish, es-ES
  • Italy, Italian, it-IT
  • Canada, English, en-CA
  • Canada, French, fr-CA
  • Australia, English, en-Au
  • Mexico, Spanish, es-MX
  • Ireland, English, en-IE
  • New Zealand, English, en-NZ
  • Belgium, French, fr-BE
  • Austria, German, de-AT
  • Switzerland, French, fr-CH
  • Switzerland, German, de-Ch
  • Singapore, English, en-SG
  • Hong Kong, English, en-HK

If you need a simple list you can store it locally and retrieve it using a number of options (resx, sql db, etc).

However if you want to detect the country based on the region/country code please consider the following option:

using System.Globalization

string countryCode = "en-US"; 
try {
    RegionInfo reg = new RegionInfo(countryCode);
        string name = reg.Name;
        string displayname = reg.DisplayName;
        string ISORegion = reg.TwoLetterISORegionName;
        string currency = reg.CurrencySymbol;
} 
catch (ArgumentException argEx) {
    // The country code was not valid 
}

More Info here: http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.aspx

Hope this helps!

In my thought, there is no API to you get all the countries supported from the Settings.

But you can refer the following link to get the all the Culture and language supported for Windows Phone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top