Answer the question
In order to leave comments, you need to log in
How to display a flat list as a tree in DataGrid or TreeView(WPF, C#)?
There is a table. It contains records of the form
ID, Name, FK
where FK points to another record in the same table.
I am using Entity Framework. The table is loaded into an ObservableCollection, for a working binding.
I can’t figure out yet how to display it as a tree in a DataGrid or in a TreeView, and in order to save the binding (do not leave the ObservableCollection that I get from the DataContext).
Maybe someone did, tell me where to dig, or maybe give an example?
Thanks
Answer the question
In order to leave comments, you need to log in
<TreeView ItemsSource="{Binding СвойствоОбщейВьюМоделиСодержащееКоллекциюЗаписей}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding СвойствоОбъектаСсылающеесяНаОбъектРодитель}" DataType="{x:Type local:КлассОбъекта}">
<TreeViewItem Header="{Binding СвойствоВОбъектеСТекстомДляОтображенияВУзле}"/>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question