Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
How to Hide Nodes without children

Hi, I'm building an application and I use a Datatree to represent a portion of the file system

I'm using the databinding of an Observable collection of FolderElements, Each item contains two collections

Subfolders and Files

The tree works perfectly representing my nodes and files, what I wanted to know is if it is possible

to Hide the Folders and Files nodes  when they are empty.

The following is an example:

[root directory]


          [Folder 1]

                [subfolders] *


                   [File 10]

                   [File 11]

        [Folder 2]


                     [Folder n1]

                        [subfolders] *


                           [file n1]



           [File on root 1]

           [file on root 2]

The Nodes marked wit the * don't have any child node, I was wondering if it is possible to avoid showing them.

The nodes are Part of a Wpf class and are represented by Dependency Properties ObservableCollection<FolderElement> and ObservableCollection<FileElement>

The two classes are dependency objects and their properties are dependency properties.

Is there a way to Hide the Empty objects?

or if this is not possible, Is it possible to Create the Node items from code behind instead of using the databinding allowing us to create them only when needed?

Thank you in advance


Parents Reply Children