|
-
Mar 31st, 2011, 02:43 PM
#1
[RESOLVED] WPF - Binding a treeview to data objects
Hi there - hope someone can help. I've been looking for examples in books and online and I just can't find anything that gets me moving forward. I've been working with traditional forms in VB since VB3 but I'm trying to get my head around WPF and MVVM but I can't for the life of me get it to do what would take 30 seconds in winforms.
I have a hierarchical structure of geographical locations so at the top level is an instance of a Location object representing "The World". This Location object also has a locations collection which has for example "Europe" and "North America" and in Europe's locations collection there might be "UK", "France", "Germany" etc.
How do I throw that collection of location objects at a treeview and make it draw the whole tree?
At the moment the best I can do is set the ItemsSource of the treeview to the "World" instance of Location, however that doesn't list any child nodes (just top level nodes, ie "World").
All the examples I can find so far for WPF treeviews rely on just XAML with a hardcoded set of nodes, or binding to a database which I'm not using.
Any pointers would be much appreciated. I'm sure its really simple but just a question of getting my head around binding in WPF.
Thanks in advance
Last edited by keystone_paul; Mar 31st, 2011 at 02:59 PM.
Reason: elaboration
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|