Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

i want to convert a WPF TreeView to XML.
I have no binding on my treeView because it will be able to load other treeView's.
With WFA you can use "nodes" but on WPF?

Tank you for answering

M
Posted
Comments
Sergey Alexandrovich Kryukov 23-Apr-14 11:25am    
"Items". What's wrong with just reading standard MSDN documentation? You are essentially asking: "Help me to read; I have problem reading". :-)
—SA

1 solution

You have everything to traverse TreeView:
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.items.aspx[^] (property of System.Windows.Controls.ItemsControl.Items and hence System.Windows.Controls.TreeView),
http://msdn.microsoft.com/en-us/library/system.windows.controls.treeviewitem%28v=vs.110%29.aspx[^] (represents a single node, also has Items property),
see also http://msdn.microsoft.com/en-us/library/system.windows.controls.treeview.aspx[^].

To write XML, .NET FCL provides different facilities. This is my short overview of them:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900