I have some hierarchical data in a Winforms TreeView control and I need to expose it as a property so my presenter can synchronize changes to it. Just to be clear, I'm using the Passive View pattern. With most WinForm controls this is a no-brainer. The controls themselves expose their data as a system type which can easily be passed along to the presenter. TreeViews, because of their complexity don't map easily to a system type. I looked for a framework collection type but tree's seem to have been overlooked. (Microsoft appears to use tree structures underneith the hood for several higher level classes but chose not to create a family of general purpose Tree classes.)
In any case the data I'm trying to expose is never more than two nodes deep so I'm not even sure I'm going to continue using TreeView. All the more reason to avoid tying the presenter to a TreeNodeCollection.
I've already come up with a few ideas but I just wanted to bounce them off the SO community:
- Expose the tree as a collection of collections... say a dictionary of lists.
- Create a custom tree structure, introducing a dependency into the view in the process.
The top-level nodes will average 5-10 entries while their child nodes could theoretically hit counts as high as 50 but in practice won't go over 3 or 4.
Any suggestions?