TreeViewItem parent = new TreeViewItem(); parent.Header = "Parent Node"; TreeViewItem child = new TreeViewItem(); child.Header = "Child Node"; parent.Items.Add(child);
TreeViewItem parent = new TreeViewItem(); parent.Header = "Parent Node"; string[] childNames = { "Child 1", "Child 2", "Child 3" }; foreach (string name in childNames) { TreeViewItem child = new TreeViewItem(); child.Header = name; parent.Items.Add(child); }Package/Library: System.Windows.Controls.