Esempio n. 1
0
        private void CountryBox_LostFocus(object sender, RoutedEventArgs e)
        {
            CountryDropdownItem item = (CountryDropdownItem)countryBox.SelectedItem;

            if (item == null)
            {
                Code = "DE";
            }
        }
Esempio n. 2
0
        public CountryDropdown()
        {
            InitializeComponent();

            XmlDocument doc = new XmlDocument();

            using (Stream stream = GetType().Assembly.GetManifestResourceStream("FlagCarrierWin.Resources.countries.xml"))
                doc.Load(stream);

            foreach (XmlNode xn in doc.SelectNodes("/countries/country"))
            {
                string cca2  = xn.Attributes["cca2"].Value;
                string names = xn.Attributes["name"].Value;

                CountryDropdownItem item = new CountryDropdownItem
                {
                    Text = cca2 + " [" + cca2 + "]",
                    Code = cca2
                };
                countryBox.Items.Add(item);

                foreach (string name in names.Split(','))
                {
                    item = new CountryDropdownItem
                    {
                        Text = name + " [" + cca2 + "]",
                        Code = cca2
                    };
                    countryBox.Items.Add(item);

                    if (!codeToItem.ContainsKey(cca2))
                    {
                        codeToItem.Add(cca2, item);
                    }
                }
            }

            Code = "DE";
        }