Work with two treeviews and their WPF items

Asked

Viewed 40 times

2

I have two similar treeviews, but with different items, in this case, one of them brings a dialogue in Portuguese while the other should bring the same dialogue 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 treeview I get one selectedDialogue = tree.SelectedItem as TreeViewItem; allocated by pointing to the item selected in the tree in English.

When I press the ADD button I add a new item to the Dialog list selected in the Portuguese dialog tree with the header of this item containing the text 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 text in Portuguese I want to search for the item of treeview in English that is in the same position of the selected dialog, I can’t find this index at all.

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 carry another treeviewitem pointing to treeview in English. Thank you all.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.