This question is locked. New answers and comments are not allowed.
I have a function that builds my tree as needed. This works and it works well. The problem is that I would like to be able to use the function FindName from RadTreeView Item in another area. so all I add to my creating of the RadTreeViewItem is Name=newNodeString.
When I do this the program crashes after return the list of nodes.
Take out that line everything, except the new feature I am trying to add, works fine.
When I do this the program crashes after return the list of nodes.
Take out that line everything, except the new feature I am trying to add, works fine.
private static void BuildTree(ItemCollection items, List<string> treeNodes,int parentIndex){ if (parentIndex >= treeNodes.Count) return; var newNodeString = treeNodes[parentIndex++]; RadTreeViewItem newNode = (RadTreeViewItem)items.FirstOrDefault((i) => (string) ((RadTreeViewItem)i).Header == newNodeString); if(newNode == null) { newNode = new RadTreeViewItem {Header = newNodeString }; if(treeNodes.Count == 0)//means this will be a child { newNode.Selected += (o, e) => { e.Handled = true; }; } else { newNode.Selected += (o, e) => { RadTreeViewItem item = o as RadTreeViewItem; if (item.HasItems) { ((RadTreeViewItem)item.Items[0]).IsSelected = true; } e.Handled = true; }; newNode.IsExpanded = true; } items.Add(newNode); } BuildTree(newNode.Items,treeNodes,parentIndex);}