Note that there are some explanatory texts on larger screens.

plurals
  1. POHiding nodes in a TreeView
    primarykey
    data
    text
    <p>Lets say we have the following collection:</p> <pre><code>ObservableCollection&lt;Node&gt; Nodes </code></pre> <p>The <code>Node</code> class has the Following collection:</p> <pre><code>ObservableCollection&lt;Leaf&gt; Leaves </code></pre> <p>where the <code>Leaf</code> class has a <code>DependencyProperty</code> named <code>IsActive</code>.</p> <p>I would like to display this data in a <code>TreeView</code>, however, I only want active leaves (a <code>Leaf</code> object where <code>IsActive</code> is <code>True</code>) to be displayed under their parent <code>Node</code>. That is, I want inactive leaves to not be displayed. I would also like nodes with no visible leaves to be hidden as well. I currently have the data displayed using a <code>HierarchicalDataTemplate</code>, but I don't know how to hide the described nodes. I have tried changing the <code>Content</code> of the <code>HierarchicalDataTemplate</code>, but the the collapsing arrow (<code>ItemContainer</code>) is still visible.</p> <p>Is there a way to achieve this? or do I just need to change the data structure? Let me know if I need to add more information or clarify something.</p> <p><strong>Update:</strong> I guess I need to clarify that I understand that I can just change <code>Node</code> and <code>Leaf</code> to achieve what I am looking for, but I would like to know if I have to do it that way. I would like to be able to use templating, styling, etc. (some xaml tricks) to achieve my desired view.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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