//------------------------------------------------------------------------------------ /// <summary> /// Worker method for BuildProductTree. /// </summary> //------------------------------------------------------------------------------------ private void BuildProductTreeWorker(List <ProductTreeNode> nodes, Node psNode) { ProductTreeNode node = new ProductTreeNode(psNode); nodes.Add(node); foreach (Node childNode in psNode.Nodes) { BuildProductTreeWorker(node.ChildNodes, childNode); } }
//------------------------------------------------------------------------------------ /// <summary> /// Internal worker for PopulateTree. /// </summary> //------------------------------------------------------------------------------------ void PopulateUITree(ItemCollection items, ProductTreeNode node) { TreeViewItem newItem = new TreeViewItem(); newItem.Header = node; items.Add(newItem); foreach (ProductTreeNode childNode in node.ChildNodes) { PopulateUITree(newItem.Items, childNode); } }
//------------------------------------------------------------------------------------ /// <summary> /// Private helper function for SelectFeatureAreaTreeNode. /// </summary> //------------------------------------------------------------------------------------ private TreeViewItem SelectTreeViewItem(System.Windows.Controls.TreeView treeView, TreeViewItem item, int treeId) { ProductTreeNode treeNode = GetTreeNodeFromTreeViewItem(item); if (treeNode.TreeID == treeId) { ExpandTreeViewItem(item); item.Focus(); item.BringIntoView(); item.IsSelected = true; return(item); } foreach (TreeViewItem childItem in item.Items) { TreeViewItem selectedItem = SelectTreeViewItem(treeView, childItem, treeId); if (selectedItem != null) { return(selectedItem); } } return(null); }
public int GetSelectedAreaTreeID(TreeView treeView) { ProductTreeNode selectedNode = GetTreeNodeFromTreeViewItem(treeView.SelectedItem as TreeViewItem); return(selectedNode == null ? -1 : selectedNode.TreeID); }