HomeWindowsRetrieve Country Name in Windows Phone 7

Retrieve Country Name in Windows Phone 7

You can get the country name in your Windows Phone 7 by using the System.Globalization assembly .

Retrieve Country Name in Windows Phone 7

Generally the System locale is set in Windows Phone 7 via Settings -> System -> Region + language where one can select the system locale and other settings for windows phone 7 .

Retreive the country name in Windows Phone 7

In this example i modified the system locale to English(India) from English(USA) .

The complete test English(India) can be retreived from the CultureInfo.CurrentCulture.EnglishName

public string CultureName()
{
     return CultureInfo.CurrentCulture.EnglishName;
}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
     MessageBox.Show(CultureName());
}
Retreive the country name in Windows Phone 7

Incase you need just the country name , you can use CurrentRegion.DisplayName or CurrentRegion.DisplayName  defined in the RegionInfo Class
.

public string GetCountryNameviaMethod1()
{
     return System.Globalization.RegionInfo.CurrentRegion.DisplayName;
}
public string GetCountryNameviaMethod2()
{
     return System.Globalization.RegionInfo.CurrentRegion.DisplayName;
}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
     MessageBox.Show(GetCountryNameviaMethod1());
     MessageBox.Show(GetCountryNameviaMethod2());
}
Retreive the country name in Windows Phone 7

It is also possible to retreive the Two letter ISO Region Name like US or IN via

TwoLetterISORegionName property defined in RegionInfo.CurrentRegion

public string GetTwoLetterISOName()
{
     return RegionInfo.CurrentRegion.TwoLetterISORegionName.ToUpper();
}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
     MessageBox.Show(GetTwoLetterISOName());
}
Retreive the country name in Windows Phone 7

Leave a Reply

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...