none
adding a treeview into a treeview RRS feed

  • Question

  • Hi,

    is possible to add in codebehind a treeview into another treeview.

    I mean, I have two XAML treeviews, and only one of its have data. Well, what I want is:

    //after InitializeComponent()

     

    this.EmptyTree.Items.Add(this.DataTree);

     

    is there any way to do this or simply is impossible??

     

    thanks.

    Friday, April 20, 2007 10:49 AM

Answers

  • Ok, I've got it.

     

    Code Snippet

    TreeViewItem tvi = new TreeViewItem();

    tvi.Header = "Head";

    tvi.ItemsSource = this.DataTree.ItemsSource;
      tvi.ItemTemplateSelector = this.DataTree.ItemTemplateSelector; //this one if your data tree have groups
      this.EmptyTree.Items.Add(tvi);

     

     Nothing more, bye

    Friday, April 20, 2007 11:38 AM