Note that there are some explanatory texts on larger screens.

plurals
  1. POHides nodes of Tree Object Recursive
    text
    copied!<p>I'm looking for a way to hides node in a tree. I'm filtering a node with a node type, this is my original structure:</p> <pre><code>root +FolderA -File1 -File2 -File3 +FolderB -File4 -File5 +FolderB-1 -File6 </code></pre> <p>This is what I'm trying to do:</p> <pre><code>+root -File1 -File2 -File3 -File4 -File5 -File6 </code></pre> <p>I have created my class XNode with a type and a list of childrens. (this is pseudo language for abbreviation)</p> <pre><code>Class XNode MyType type; string Name; List&lt;XNode&gt; childrens; End Class </code></pre> <p>I have created a factory class that query my database and create original tree.</p> <p>I have created a Xaml treeView UserControl to bind my root XNode created.</p> <p>Via Xaml is not possible to hide a Node, this operation must be done with binded object (my root Xnode created).</p> <p><strong>Now my question is: There are recursive alghoritms to cancel a "Folder type" node, get its childrens and add them to parent Node?</strong></p> <p>I'm try:</p> <pre><code> public XNode RemoveFoldersElements(ref XNode rootNode) { if (rootNode != null) { if (rootNode.Children.Count &gt; 0) { for (int i = 0; i &lt; rootNode.Children.Count; i++) { XNode children = rootNode.Children.ElementAt(i); if (children.WType == NodeType.Type_FOLDER) { XNode tempNode = RemoveFoldersElements(ref children); if (tempNode != null) rootNode.Children.Add(tempNode); rootNode.Children.RemoveAt(i); } else { RemoveFoldersElements(ref children); } } } } return null; } </code></pre> <p>but not success because not all nodes of Type_FOLDER are erased (it jump one level) ! Any Idea?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload