public TreePageViewModel(TreeNode[] nodes) { Nodes = nodes; _details = this.WhenAnyValue(x => x.SelectedNode) .Select(x => x != null ? new ControlDetailsViewModel(x.Control) : null) .ToProperty(this, x => x.Details); }
private void ExpandNode(TreeNode node) { if (node != null) { node.IsExpanded = true; ExpandNode(node.Parent); } }
public VisualTreeNode(IVisual visual, TreeNode parent) : base((Control)visual, parent) { var host = visual as IVisualTreeHost; if (host?.Root == null) { Children = visual.VisualChildren.CreateDerivedCollection(x => new VisualTreeNode(x, this)); } else { Children = new ReactiveList<VisualTreeNode>(new[] { new VisualTreeNode(host.Root, this) }); } if (Control != null) { IsInTemplate = Control.TemplatedParent != null; } }
public void SelectControl(IControl control) { var node = default(TreeNode); while (node == null && control != null) { node = FindNode(control); if (node == null) { control = control.GetVisualParent<IControl>(); } } if (node != null) { SelectedNode = node; ExpandNode(node.Parent); } }
private TreeNode FindNode(TreeNode node, IControl control) { if (node.Control == control) { return node; } else { foreach (var child in node.Children) { var result = FindNode(child, control); if (result != null) { return result; } } } return null; }
public LogicalTreeNode(ILogical logical, TreeNode parent) : base((Control)logical, parent) { Children = logical.LogicalChildren.CreateDerivedCollection(x => new LogicalTreeNode(x, this)); }