Robert Hurd

Robert Hurd

  • NA
  • 1
  • 2.4k

Trouble Building Multilevel TreeView Object Hierarchy

Apr 26 2012 12:50 PM
Hi there,

Firstly thank you for taking the time out to read this post.
I'm having difficulty creating a WPF TreeView Hierarchy object. The object may have many child nodes, which in turn may also have many child nodes. The number of node levels need to be unlimited. Some nodes may have more levels than others.

I've tried creating an example but currently I can only construct a Hierarchy 2 levels deep.

I have attached my source code for the project. All it contains is the treeview control and c# objects, methods and classes for this particular problem.

When you open the source code, open file MainWindow.cs and find the Window_Loaded() method. Within the method you'll notice I'm trying to create a list of items with ID, ParentID & Name. The problem I have is that the items with ID=6 & ID=7 aren't being created when I convert the flat list into an hierarchal object, thus not visible in the treeview control when the ItemSource is set.

Thank you very much for your time. All help is appreciated.

Attachment: wpfapplication1-2.zip