# .NET and More > WPF, WCF, WF >  WPF Treeview (Adding Parent Nodes Dynamically)

## Ajx123

Hello Friends
I am new in WPF, I am developing wpf Application. I want to use WPF Treeview control. I did some RND on Google and I found that we have to create Parent child relationship between two tables and assign that relationship in .XAML file of the form and so on. My question is that can we  add Parent /child Nodes to Treeview control dynamically using C#, the way it is done in Windows application. If Yes than please provide a link. 
-@jay-

----------


## dee-u

If you know how to add nodes using C# then it should also be easy adding nodes in WPF using C#. Here is a quick sample.


```
private void button1_Click(object sender, RoutedEventArgs e)
{
    TreeViewItem parent = new TreeViewItem();
    parent.Header = "parent";
    TreeViewItem child1 = new TreeViewItem();
    child1.Header = "child1";
    TreeViewItem child2 = new TreeViewItem();
    child2.Header = "child2";
    parent.Items.Add(child1);
    parent.Items.Add(child2);

    TreeView1.Items.Add(parent);
}
```

----------


## Ajx123

thank you very Much for the Code

----------

