0

I have a list with strings which i would like to turn into a Tree view. The strings are the folder names of ones (exchange) Inbox. The strings would look like this

string a "Username\Inbox"
string b "Username\Inbox\Subfolder"
string c "Username\inbox\subfolder"
string d "Username\Createdfolder"
string e "Username\Createdfolder\subfolder"

I have all those strings in a list and would like to turn it into a treeview. I have read i could turn it all into XML and it would be able to load it. But to be honest i dont know where to start to make this into xml so i can bind it to a treeview. Ofcourse if there is a better way to bind them please tell me.

Kage
  • 451
  • 1
  • 7
  • 18
  • 1
    Google is your friend: http://stackoverflow.com/questions/1155977/populate-treeview-from-a-list-of-path , http://stackoverflow.com/questions/13253232/how-to-populate-treeview-with-file-path-which-is-saved-in-database , http://stackoverflow.com/questions/6415037/populate-treeview-from-list-of-file-paths-in-wpf ,... – Arie Jul 03 '13 at 13:24
  • @Arie Ohh! Thanks for the link. the first link is EXACTLY what i was looking for. sorry for not finding it on my own! – Kage Jul 03 '13 at 14:20

1 Answers1

0

Try this format:

  <nodes>
    <node name="a" value="Username\Inbox"/>
    <node name="b" value="Username\Inbox\Subfolder"/>
    <node name="c" value="Username\inbox\subfolder"/>
    <node name="d" value="Username\Createdfolder"/>
    <node name="e" value="Username\Createdfolder\subfolder"/>
  </nodes>

in c# put

        string xml =
        "<nodes>" +
            "<node name=\"a\" value=\"Username\\Inbox\"/>" +
            "<node name=\"b\" value=\"Username\\Inbox\\Subfolder\"/>" +
            "<node name=\"c\" value=\"Username\\inbox\\subfolder\"/>" +
            "<node name=\"d\" value=\"Username\\Createdfolder\"/>" +
            "<node name=\"e\" value=\"Username\\Createdfolder\\subfolder\"/>" +
        "</nodes>";
jannagy02
  • 2,213
  • 1
  • 22
  • 42
  • Thanks for showing how the format would have worked! i decided to follow one of the links Arie linked in the command since it seems easier, but thanks for the XML Example!. – Kage Jul 03 '13 at 15:47