从Windows Phone 8获取国家/地区名称

我有截图

在此处输入图像描述

我打算找回应该是“尼日利亚”的国家。 在浏览System.Globalization类之后,我找到了下面的代码片段

System.Globalization.RegionInfo.CurrentRegion.EnglishName 

但我得到的是“美国”,这是上图所示的“地区格式”。 我无法检索国家/地区值设置吗?

我知道它已经老了,但也许有人来这里寻找答案:

 System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName 

使用System.Threading.Thread.CurrentThread.CurrentCulture. 它应该正确反映手机语言。

试试这个

 System.Globalization.RegionInfo.CurrentRegion.DisplayName; 

用户问的正确答案是:

 Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion 

这应该为您提供有关语言+区域设置中的国家/地区选择的信息。

这就是我在一天结束时所做的。 首先,我使用Location API库来获取该位置的坐标(经度和纬度)

  Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 50; try { // Request the current position Geoposition geoposition = await geolocator.GetGeopositionAsync( maximumAge: TimeSpan.FromMinutes(5), timeout: TimeSpan.FromSeconds(10) ); string latitude = geoposition.Coordinate.Latitude.ToString("0.00"); string longitude = geoposition.Coordinate.Longitude.ToString("0.00"); } catch (Exception ex) { if ((uint)ex.HResult == 0x80004004) { // the application does not have the right capability or the location master switch is off MessageBox.Show("Location is disabled in phone settings.", "Can't Detect Location", MessageBoxButton.OK); } //else { // something else happened acquring the location System.Diagnostics.Debug.WriteLine(ex.Message); } } 

然后使用谷歌的反向地理位置,根据经度和纬度获取位置的信息或细节

 http://maps.googleapis.com/maps/api/geocode/json?latlng=latitiude,longitude&sensor=true 

即如果纬度为60且经度为60

 http://maps.googleapis.com/maps/api/geocode/json?latlng=60,60&sensor=true 

从json结果中,您将能够检索该国家的长短名称。