• C#解析Xaml


          XmlDocument doc = new XmlDocument();
                doc.Load(@"K:\Users\yuanchao\Documents\visual studio 2012\Projects\App3\App3\Dictionary1.xaml");
                //XmlNode xn = doc.SelectSingleNode("bookste");
                XmlNode xn = doc.ChildNodes[0];
                XmlNodeList xnList = xn.ChildNodes;
                Dictionary<string, string> dictinoary = new Dictionary<string, string>();
                foreach (XmlNode xnode in xnList)
                {
                    string strKey = "";
                    string strBase = "";
    
                    foreach (XmlAttribute xmlatt in xnode.Attributes)
                    {
                        if (xmlatt.Name == "x:Key")
                        {
                            strKey = xmlatt.Value.ToString();
                        }
    
                        if (xmlatt.Name == "BasedOn")
                        {
                            strBase = xmlatt.Value.ToString();
                            strBase = strBase.Replace("{StaticResource", "").Replace("}", "").Trim();
                        }
                    }
                    dictinoary.Add(strKey, strBase);
                }
    
                TreeViewItem itemheader = new TreeViewItem();
                itemheader.Header = "Buttonstylebase";
                TreeViewName.Items.Add(itemheader);
    
    
                foreach (KeyValuePair<string, string> str in dictinoary)
                {
                    if (str.Value.ToString() == itemheader.Header.ToString())
                    {
                        TreeViewItem item1 = new TreeViewItem();
                        item1.Header = str.Key.ToString();
                        itemheader.Items.Add(item1);
                    }
                }
                

    后台加载数据  在页面上显示出来

    http://code.msdn.microsoft.com/windowsapps/Print-Sample-c544cce6

  • 相关阅读:
    angular模板
    Growth: 全栈增长工程师指南
    全栈增长工程师实战
    vue 快速搭建项目 iview
    ng-style
    教程视频链接
    内置对象
    对象—封装、继承
    对象—构造函数
    函数-理论
  • 原文地址:https://www.cnblogs.com/gengyuanchao/p/2880641.html
Copyright © 2020-2023  润新知