In my application, I'm able to bind a TreeView to a Well object in my application through object-relational binding as such:
this.wellTreeView = new RadTreeView();
BindingList<Well> wells = new BindingList<Well>() { well };
this.wellTreeView.DataSource = wells;
this.wellTreeView.DisplayMember = "name\\name\\name";
this.wellTreeView.ChildMember = "wells\\layers\\items";
This works and I am able to view the TreeView hierarchy and select the nodes in the form. However, when trying to get the nodes in code, the wellTreeView is empty (0 nodes) and throws an Index out of range error in:
RadTreeNode node = wellTreeView.Nodes[0];
My Well class is defined like so:
public class Well
{
public string name {get; set;}
public List<Layer> layers {get; set;}
}
public class Layer
{
public string name {get; set;};
public List<Item> items {get; set;}
}
public class Item
{
public string name {get; set;};
public decimal length {get; set;}
}
I don't understand why the wellTreeView is empty without any nodes despite being able to view the tree in the form. Surely the well is bound to the TreeView?