Results 1 to 3 of 3

Thread: WPF Treeview (Adding Parent Nodes Dynamically)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Location
    Mumbai
    Posts
    94

    Cool 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-

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    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);
    }
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Location
    Mumbai
    Posts
    94

    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
  •  



Click Here to Expand Forum to Full Width