Esempio n. 1
0
        private async Task ClearCountries()
        {
            capitalOfCountry.DataContext = null;

            countryList = null;
            comboboxCountries.ItemsSource = null;
            countryListFetcher            = null;
            totalCountries.Text           = string.Empty;

            await Task.Delay(10);
        }
Esempio n. 2
0
        private async Task LoadCountries()
        {
            // Instantiate the class
            countryListFetcher = new CountryListDataFetcher();

            // Set the network access timeout (milliseconds)
            countryListFetcher.networkTimeout = 3000;
            // Get the list of continents
            countryList = await countryListFetcher.fetchCountries();

            // Process the list of countries found
            if (countryList != null)
            {
                // Bind the list to the UI
                comboboxCountries.ItemsSource   = countryList;
                comboboxCountries.SelectedIndex = 0;

                // ISSUE - DOES NOT DISPLAY THE CAPITAL OF THE COUNTRY THE FIRST TIME
                capitalOfCountry.DataContext = countryList;

                // Display the number of coutries
                totalCountries.Text = countryList.Count.ToString();
            }
        }