title: How should I expose hierarchical data from a TreeView control to a MVP presenter?
body: <p>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 <em>Passive View</em> 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 <em>Tree</em> classes.)</p>
  
  <p>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.</p>
  
  <p>I've already come up with a few ideas but I just wanted to bounce them off the SO community:</p>
  
  <ul>
  <li>Expose the tree as a collection of collections... say a dictionary of lists.</li>
  <li>Create a custom tree structure, introducing a dependency into the view in the process.</li>
  </ul>
  
  <p>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.</p>
  
  <p>Any suggestions?</p>