示例#1
0
        private void InitializeDropDown()
        {
            XmlDocument doc     = new XmlDocument();
            var         dirPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            doc.Load(dirPath + @"\ViewAndUI\ResourceManager\Resource\lang_country_lists.xml");
            XmlNode nodeEle = doc.SelectSingleNode("//languages");


            XDocument document = XDocument.Load(dirPath + @".\ViewAndUI\ResourceManager\Resource\lang_country_lists.xml");

            langMap = document.Descendants("languages").Descendants("lang")
                      .ToDictionary(d => (string)d.Attribute("id"),
                                    d => (string)d.Attribute("name"));

            int           c          = langMap.Count;
            ExpandoObject utilExpObj = ResourceManagerUtil.getExpandoObj();

            foreach (XmlElement nodeE in nodeEle.ChildNodes)
            {
                AddProperty(expando, nodeE.GetAttribute("id"), nodeE.GetAttribute("name"));
                ResourceManagerUtil.AddProperty(utilExpObj, nodeE.GetAttribute("name"), nodeE.GetAttribute("id"));
            }

            XmlElement   node        = doc.CreateElement("lang");
            XmlAttribute idAttribute = doc.CreateAttribute("id");

            idAttribute.Value = "default_All";

            XmlAttribute nameAttribute = doc.CreateAttribute("name");

            nameAttribute.Value = "All";

            node.Attributes.Append(idAttribute);
            node.Attributes.Append(nameAttribute);

            nodeEle.InsertBefore(node, nodeEle.ChildNodes.Item(0));
            configLangCombo.ItemsSource = nodeEle;
            //configLangComboView.ItemsSource = nodeEle;
        }