문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top