Working with two treeviews and their items in WPF

2

I have two similar treeviews, but with different items, in the case, one of them brings a dialog in Portuguese while the other one should bring the same dialog in English. I have two text boxes, one to put the text in English another to put the text in Portuguese.

When I select an item from the treeview I get a selectedDialogue = tree.SelectedItem as TreeViewItem; allocated pointing to the item selected in the tree in Portuguese.

When I press the ADD button, I add a new item to the selected Dialogue list in the Portuguese dialog tree with the header of this item containing the text box of the Portuguese text box.

So far, everything happens in the right way, the texts appear and the tree in Portuguese is loaded, but at the same point where I add the Portuguese text I want to search for the treeview item in English that is in the same position as the selected dialog. I can find this index in any way.

private void btnAdd_Click(object sender, RoutedEventArgs e)
    {
        TreeViewItem itemTemp = new TreeViewItem();
        itemTemp.Header = txtLanguagePTDialogue.Text;
        selectedDialogue.Items.Add(itemTemp);

        this.txtLanguagePTDialogue.Text = string.Empty;

        if(!String.IsNullOrEmpty(this.txtLanguageENDialogue.Text))
        {
            TreeViewItem itemTempEN = new TreeViewItem();
            itemTemp2.Header = txtLanguageENDialogue.Text;

            var itemDialogueEN = trDialoguesEN.Items[selectedDialogue.PersistId] as TreeViewItem;
            itemDialogueEN.Items.Add(itemTempEN);
        }
    }

I need ideas, I did not want to load another treeviewitem pointing to the treeview in English. Thank you all.

    
asked by anonymous 01.06.2016 / 20:07

0 answers