none
How to use treeview in wpf? RRS feed

  • Question

  • Hi!

    I dont get the treeviewcontrol in wpf. Apparently it's supposed to be easier than winforms. Guess that means im just dumb :P

    lets say you had an array of strings like

    "All Books"
    "All books\programming"
    "All books\programming\c#"
    "All books\programming\visual basic"
    "All books\Database"
    "All books\Database\Sql server"
    "All books\Sci-fi"

    how would you make this into a treeview?

    wpf dont have the treenode object so im struggling :)


    Friday, December 19, 2008 1:16 PM

Answers

  • I really recommend everybody to read Josh Smith articles on TreeViews.

    Here

    Here

    And here.

    After reading those I haven't had any problem with WPF TreeViews at all.
    Friday, December 19, 2008 2:56 PM
  • <TreeView> 
      <TreeViewItem Header="AllBooks"
        <TreeViewItem Header="programming"
          <TreeViewItem Header="c#"/> 
          <TreeViewItem Header="visual basic"/> 
        </TreeViewItem> 
        <TreeViewItem Header="Database"
          <TreeViewItem Header="Sql server"/> 
        </TreeViewItem> 
        <TreeViewItem Header="Sci-fi"/> 
      </TreeViewItem> 
    </TreeView> 

    If you want to retrieve the data directly from that string array you can do this dynamically.

    Bigsby, Lisboa, Portugal
    Friday, December 19, 2008 2:33 PM
  • Expression Blend is having TreeView Control.

    Click on Asset Library  [>>] button in the toolbar
    and in search box type tree you will get treeview control, treenode control etc.


    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Friday, December 19, 2008 2:42 PM
    • Marked as answer by Jim Zhou - MSFT Thursday, December 25, 2008 10:16 AM
    Friday, December 19, 2008 2:42 PM

All replies

  • <TreeView> 
      <TreeViewItem Header="AllBooks"
        <TreeViewItem Header="programming"
          <TreeViewItem Header="c#"/> 
          <TreeViewItem Header="visual basic"/> 
        </TreeViewItem> 
        <TreeViewItem Header="Database"
          <TreeViewItem Header="Sql server"/> 
        </TreeViewItem> 
        <TreeViewItem Header="Sci-fi"/> 
      </TreeViewItem> 
    </TreeView> 

    If you want to retrieve the data directly from that string array you can do this dynamically.

    Bigsby, Lisboa, Portugal
    Friday, December 19, 2008 2:33 PM
  • Expression Blend is having TreeView Control.

    Click on Asset Library  [>>] button in the toolbar
    and in search box type tree you will get treeview control, treenode control etc.


    Prasad - www.beautifulmind.blog.co.in
    • Proposed as answer by prasad22 Friday, December 19, 2008 2:42 PM
    • Marked as answer by Jim Zhou - MSFT Thursday, December 25, 2008 10:16 AM
    Friday, December 19, 2008 2:42 PM
  • I really recommend everybody to read Josh Smith articles on TreeViews.

    Here

    Here

    And here.

    After reading those I haven't had any problem with WPF TreeViews at all.
    Friday, December 19, 2008 2:56 PM