Exploring the CodeFluent Runtime: Country utilities
The CodeFluent.Runtime.Utilities.Country class is a cool tool that provides information about countries, regions, geographic locations and currencies.
Below is a figure showing a WPF application with a DataGrid that contains a list of countries with the information this class provides: locale identifier, region, english name, native name (in the corresponding language), currencies, etc.)
<Grid> <DataGrid x:Name="MyDataGrid" /> </Grid>
MyDataGrid.ItemsSource = CodeFluent.Runtime.Utilities.Country.AllCountries;
By running the code above, you’ll get a list of countries as a data source for your WPF DataGrid.
The Country object also exposes some useful methods such as:
GetCountry : find a country by its ISO-3166 two-letter code
It also supports principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166 so you can get locations and not only countries:
// *private joke* Carl, this one's for you ! var guadeloupe = CodeFluent.Runtime.Utilities.Country.GetCountry("GL"); // Get all locations installed on your system. var allLocations = CodeFluent.Runtime.Utilities.Country.AllLocations;
GetCurrencyCountries : find countries for a given ISO currency symbol
var euroCountries = CodeFluent.Runtime.Utilities.Country.GetCurrencyCountries("EUR")
So here is the same grid with the list of countries that use EURO currency:
Before leaving this topic, I suggest you have also have a look at the CultureComboBox control available in the CodeFluent.Runtime.Design namespace. It provides an associated Winforms ComboBox specialized for displaying countries.
The R&D team.