Reputation: 106
I'm trying to create a treeview similar to the accounts view in Outlook.
Essentially I'm looking for the following structure.
1 First Account name
1.1 Inbox
1.2 Deleted Items
1.3 Sent Items
2 Second Account Name
2.1 Inbox
2.2 Deleted Items
2.3 Sent Items
The number of accounts (root nodes) is variable according to the user.
The number of leaf nodes is constant.
If possible, I'd like to restrict the selection of the root elements, there's no point selecting one of those, they don't "do" anything.
Obviously, I also need to be able to track which leaf node was selected.
Any help would really be appreciated, I'm going round in circles with this one.
(I have tried to follow Josh Smith's article on CodePlex but that's only added to the confusion for now).
Thanks,
CA.
Upvotes: 0
Views: 262
Reputation: 921
From experience, you may not actually want to use a TreeView for this. They use a hierarchical data template which is very useful if you're using parent-child relationships of the same type that go many levels deep. You're only going three levels deep, though, and no two levels share a type.
You might want to consider nested ItemsControls styled to look like trees. By toggling or animating the visibility of the subordinate ItemsControls based on a ToggleButton, you can get similar functionality to a TreeView without the headache.
Josh Smith's article is pretty much the gospel for heirarchical data templates. If what he's suggesting isn't working, it is likely because it's a square-peg-round-hole situation.
Upvotes: 1