private void AddNodeToTree(SvgElement eleParent, SvgElement eleToAdd, SvgElement eleBefore) { if (eleToAdd == null) { return; } string sNodeName = eleToAdd.GetElementName(); string sId; sId = eleToAdd.Id; if (sId != "") { sNodeName += "_"; sNodeName += sId; //sNodeName += ")"; } TreeViewItem node = new TreeViewItem { Name = sNodeName }; node.Tag = eleToAdd.GetInternalId(); TreeViewItem nodeParent = null; TreeViewItem nodeBefore = null; if (eleParent != null) { nodeParent = FindNodeByTag(null, eleParent.GetInternalId().ToString()); } if (eleBefore != null) { nodeBefore = FindNodeByTag(nodeParent, eleBefore.GetInternalId().ToString()); } if (nodeParent == null) { if (nodeBefore == null) { TreeViewPrintFile.Items.Add(node); } else { //TreeViewPrintFile.Items.Insert(nodeBefore.Index, node); } } else { if (nodeBefore == null) { nodeParent.Items.Add(node); } else { //nodeParent.Items.Insert(nodeBefore.Index, node); } } //node.ImageIndex = (int)eleToAdd.getElementType(); //node.SelectedImageIndex = nod.ImageIndex; //node.Expand(); if (eleToAdd.GetChild() != null) { AddNodeToTree(eleToAdd, eleToAdd.GetChild(), null); SvgElement nxt = eleToAdd.GetChild().GetNext(); while (nxt != null) { AddNodeToTree(eleToAdd, nxt, null); nxt = nxt.GetNext(); } } TreeViewPrintFile.Items.MoveCurrentTo(node); }