/// <summary> /// Sets the first visible node in the tree. Clears all nodes if not empty. /// </summary> /// <param name="node"></param> public void SetTopNode(DataViewNode node) { // clear nodes if not empty if (Nodes.Count != 0) { Nodes.Clear(); } // initialize its view as it will be the first visible node node.InitializeView(); // add top node Nodes.Add(node); }
public void ExpandNode(DataViewNode viewModel) { // check if the first child node is a dummy node if (viewModel.Nodes.Count > 0 && viewModel.Nodes[0].Text.Length == 0) { // initialize the view so the user doesn't get to see the dummy node viewModel.InitializeView(true); } foreach (DataViewNode childNode in viewModel.Nodes) { if (childNode.Nodes.Count == 0 && childNode.NodeFlags.HasFlag(DataViewNodeFlags.Branch)) { // HACK: add a dummy node for each branch // so the expand icon shows up even when a node hasn't initialized yet childNode.Nodes.Add(new TreeNode()); } } }