-
Sep 19th, 2010, 10:57 AM
#1
Thread Starter
Lively Member
WPF Treeview (Adding Parent Nodes Dynamically)
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-
-
Sep 20th, 2010, 01:10 AM
#2
Re: WPF Treeview (Adding Parent Nodes Dynamically)
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.
Code:
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);
}
-
Sep 20th, 2010, 01:13 AM
#3
Thread Starter
Lively Member
Re: WPF Treeview (Adding Parent Nodes Dynamically)
thank you very Much for the Code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|