Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Add childs to a xamdatatree node
posted


private XamDataTreeNode LoadTree(XmlNode dataNode, int index)
{
XamDataTreeNode visualNode = new XamDataTreeNode(index, null, MakeTextBox(dataNode.Name), false, null);

int count = 0;
foreach (XmlNode child in dataNode.ChildNodes)
{
visualNode.Nodes.Add(LoadTree(child, count++));
}

visualNode.IsExpanded = true;

//IEntityCollection collection1 = factory.FetchMulti(filterObject);
return visualNode;
}

This code causes NullReferenceException because visualNode.Nodes is not initialized. I failed to initialize this myself as this property is read-only.

I have a multi-level tree structure and must load data based on the position in that structure. Also I must analyze the children to define the looks for the current node. The datatree can start anywhere on the predefined structure.

These requirements are so specific that I've given up on using databinding right away.