Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Fill a TreeView with differents types of objects

$
0
0

Hi everybody,

I have a question about TreeView. In my application, I have two types of objects : "Folder" and "Server".
I have a list of folders (ObservableCollection<Folder> Childs). Each folder can contain an other list of subfolders (ObservableCollection<Folder> Childs) that can contain a list of servers (ObservableCollection<Server>).

-Folder
--Folder
---Server
---Server
-Folder
--Folder
---Server

I would like to have the root list of folders as ItemsSource of a TreeView and show its subfolders and the servers in each subfolder. What is the best way to do that ? I read many things about DataTemplateSelector but I don't know how to use it. It is a bit complicated...

Thanks in advance for your suggestions.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>