Display “root” node in TreeView?

If you want a root you need to specify an ItemsSource with only one item in it, the root node, it has to be an IEnumerable the node itself cannot be the source.

Up vote 0 down vote favorite share g+ share fb share tw.

This is my code: Node node0 = new Node("Root"); Node node1 = new Node("Node1-1"); Node node12 = new Node("Node1-2"); Node node21 = new Node("Node2-1"); Node node22 = new Node("Node2-2"); Node node31 = new Node("Node3-1"); Node node9 = new Node("Node9"); node12.Children. Add(node21); node12.Children. Add(node22); node22.Children.

Add(node31); node1.Children. Add(node9); node0.Children. Add(node1); node0.Children.

Add(node12); treeView1. DataContext = node0; public class Node { List children; public List Children { get { return children; } set { children = value; } } string data; public string Data { get { return data; } set { data = value; } } public Node() { children = new List(); } public Node(string data) : this() { this. Data = data; } } c# wpf xaml treeview link|improve this question edited Jun 10 '11 at 15:08 asked Jun 10 '11 at 14:15anderi766 55% accept rate.

If you want a root you need to specify an ItemsSource with only one item in it, the root node, it has to be an IEnumerable, the node itself cannot be the source.

– anderi Jun 10 '11 at 15:11 Something like: treeView. ItemsSource = new List() { rootNode }; – H.B. Jun 10 '11 at 15:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions