Bind Treeview to object with list of same object in WPF?

You need to use a HierarchicalDataTemplate.

Up vote 1 down vote favorite share g+ share fb share tw.

I'm trying to make a report treeview thing. Where I could write some text to have as a parent node, and if need be I'd add add strings as sub nodes to display some more information. I made a report object: public class Report { private List reportList = new List(); public string Text { get; set; } public List Reports { get { return reportList; } set { reportList = value; } } } Then I'd have a Report Collection that I would then feed into a treeview itemssource, but I have no idea how to create the bindings so that it will create the subnodes properly throughtout, I tried searching google, but I couldn't find the correct way.

Can anybody inhere help me? C# wpf binding treeview nodes link|improve this question asked Oct 27 '11 at 11:41Xenoxsis216.

Oh my...I thought I did that already, but I guess I must've messed up the bindings or something. Thanks a bunch. Could I perhaps ask a followup?

Say I then had a person object who had: FirstName, LastName, Adress, Sex, Height. And in the parent node you'd only want to show the First and Last name, but in the subnodes they'd have all information (a master detail of sorts) I can't use hierachical data for that right? – Xenoxsis Oct 27 '11 at 12:05 1 @Xenoxsis: Instead of using the DataType property to select a HierarchicalDataTemplate based on the type of the element in the tree (which doesn't differentiate between same type of element at different levels) you can use the ItemTemplate property to specify another HierarchicalDataTemplate for the next level.

– Martin Liversage Oct 27 '11 at 12:14.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions