When I make a list box in WPF I frequently set its ItemsSource to be a List. Is there a Tree for TreeView (or what goes in ItemsSource for TreeView)?
Is there a collection or generally accepted method for handling tree data in C#.NET?
When I make a list box in WPF I frequently set its ItemsSource to be a List. Is there a Tree for TreeView (or what goes in ItemsSource for TreeView)?
Is there a collection or generally accepted method for handling tree data in C#.NET?
It is certainly possible to data bind a source to a WPF TreeView
instance. Here are a couple of blogs and sample entries on the subject
Nothing built in as far as I know. What I usually do is something like this:
class User
{
string Name { get; set; }
List<User> { get; set; }
}
Then you can use that to bind to your hierarchical control, such as a TreeView.
There is an open source project that was originally by Wintellect, found here, called PowerCollections. Maybe there is something there that might help you?
Hope this helps, Best regards, Tom.
You might want to look at binding XML via XLinq to your treeview, such as here: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/02a47e46-12e9-45fb-af18-4511f2212acb/ and here: http://www.beacosta.com/blog/?p=50.
What you want to do is bind a collection of hierarchical objects to the tree view using the Hierarchical Data Template.
I have written a blog post on this very subject, check it out,