You just need to keep a reference to the TreeViewItem
that has just created and Add the Items to that treeViewItem
TreeViewItem treeItem = null;
treeItem = new TreeViewItem();
treeItem.Header = "Audit";
foreach (cAuditTransactionTypeEntity tt in _Pot)
{
TreeViewItem createdTV ;
char[] charsToTrim = {' ', '\t' };
//Keep a reference to the created TreeViewItem
createdTV = new TreeViewItem() { Header = tt.TransactionType, Name = tt.TransactionType.Replace(" ", "")}
//Create the childs of the createdTreeView
foreach (cAuditTransactionTypeEntity otherInfo in _OtherList)
{
createdTV.Items.Add(new TreeViewItem() { Header = otherInfo.TransactionType, Name = otherInfo.TransactionType.Replace(" ", "")}) ;
}
treeItem.Items.Add(createdTV);
}
ToDoList.Items.Add(treeItem);
If what you need to do is a look for a specific child and add items to it...
foreach (TreeviewItem objTreeviewItem in ToDoList.Items)
{
//change to the desired transaction type
if ((objTreeviewItem.Header == "TransType")) in your comments
{
//add the IDs that correspond to the transaction type
objTreeviewItem.Items.Add(new TreeViewItem() { Header = child.ID, Name = child.Name}) ;
}
}