private static void WalkThroughTree(DependencyObject node, DependencyObject excludedNode, Visitor visitor, bool isLast = true) { if (node != null) { // Assume that if we have a UIElement, we'll have some properties visitor.BeginVisitNode(node, node is UIElement); var childrenCount = VisualTreeHelper.GetChildrenCount(node); WalkThroughProperties(node, visitor, childrenCount != 0); if (childrenCount != 0) { visitor.BeginChildren(); for (int i = 0; i < childrenCount; i++) { var child = VisualTreeHelper.GetChild(node, i); if (child != excludedNode) { bool isLastChild = (i == childrenCount - 1); WalkThroughTree(child, excludedNode, visitor, isLastChild); } } visitor.EndChildren(); } visitor.EndVisitNode(node, isLast); } }
private static void WalkThroughTree(DependencyObject node, DependencyObject excludedNode, Visitor visitor, bool isLast = true) { if (node != null && visitor.ShouldVisitPropertiesForNode(node)) { // Assume that if we have a UIElement, we'll have some properties var children = GetChildren(node, visitor); bool hasProperties = node is UIElement || (children.Length > 0); visitor.BeginVisitNode(node, hasProperties); WalkThroughProperties(node, visitor, children.Length != 0); if (children.Length != 0) { visitor.BeginChildren(); for (int i = 0; i < children.Length; i++) { var child = children[i]; if (child != excludedNode) { bool isLastChild = (i == children.Length - 1); WalkThroughTree(child, excludedNode, visitor, isLastChild); } } visitor.EndChildren(); } visitor.EndVisitNode(node, isLast); } }
private static void WalkThroughTree(DependencyObject node, Visitor visitor) { if (visitor.ShouldVisitNode(node)) { visitor.BeginVisitNode(node); WalkThroughProperties(node, visitor); for (int i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++) { WalkThroughTree(VisualTreeHelper.GetChild(node, i), visitor); } visitor.EndVisitNode(node); } }
private static void WalkThroughTree(DependencyObject node, DependencyObject excludedNode, Visitor visitor) { if (node != null) { visitor.BeginVisitNode(node); WalkThroughProperties(node, visitor); for (int i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++) { var child = VisualTreeHelper.GetChild(node, i); if (child != excludedNode) { WalkThroughTree(child, excludedNode, visitor); } } visitor.EndVisitNode(node); } }