Silverlight Read configuration file

Source: Internet
Author: User

1.extranetlink.xml

<?xml version="1.0"encoding="Utf-8"?><menus> <menu header="Comprehensive Water Conservancy network"> <extranet linkname="Baidu Network"Linkadd="http://www.baidu.com"/> <extranet linkname="- Degree Cable"Linkadd="http://www.baidu.com"/> <extranet linkname="Computer informatization"Linkadd="http://www.baidu.com"/> <extranet linkname="Silverlight Committee"Linkadd="http://www.baidu.com"/> <extranet linkname="Central Meteorological Bureau"Linkadd="http://www.baidu.com"/> <extranet linkname="United Nations"Linkadd="http://www.baidu.com"/> </menu> <menu header="Provincial Weather Network"> <extranet linkname="Central Meteorological Bureau"Linkadd="http://www.baidu.com"/> <extranet linkname="Hebei"Linkadd="http://www.baidu.com"/> <extranet linkname="Beijing"Linkadd="http://www.baidu.com"/> <extranet linkname="Add"Linkadd="http://www.baidu.com"/> <extranet linkname="Modify"Linkadd="http://www.baidu.com"/> <extranet linkname="Baidu Network Disk"Linkadd="http://www.baidu.com"/> </menu> </menus>

2. Read the XML file

Private void Getxmldatatask_beforestart (object  sender, EventArgs e)        {            as  Task;             " Extranetlink.xml " ;             typeof (String);        }

3. Working with files

 Private voidGetxmldatataskcallback (Response Response) {tabConExtranet.Items.Clear (); XDocument Document=Xmlparsehelper.xmlparse (response.            datastring);  This. Dispatcher.begininvoke (() ={IEnumerable<XElement> elements = document. Descendants (Xname.get ("Menu")); foreach(XElement Parentinchelements) {TabItem TabItem=NewTabItem (); Tabitem.header= parent. Attribute (Xname.get ("Header")).                    Value; Tabitem.style= app.current.resources["Tabitemstyle"] asStyle; StackPanel SP=NewStackPanel (); Tabitem.content=sp; Sp. Orientation=Orientation.horizontal; IEnumerable<XElement> Childs = parent. Descendants (Xname.get ("Extranet")); foreach(XElement ChildinchChilds) {Hyperlinkbutton Hyper=NewHyperlinkbutton (); Hyper. TargetName="_blank"; Hyper. Content=string. Concat ("", child. Attribute (Xname.get ("linkname")).                        Value); Hyper. NavigateUri=NewUri (child. Attribute (Xname.get ("Linkadd")).                        Value); Hyper. Style= app.current.resources["HyperLinkStyle"] asStyle; Sp.                    Children.add (hyper);                } tabConExtranet.Items.Add (TabItem);        }            }); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.