title: How to properly design event for nested data?
body: <p>Currently, I'm having hard time trying to find a proper way designing event system for an API.</p>
  
  <p><strong>Situation:</strong>
  There are few classes (named WPoint, CPoint, OPoint...) which contains a lot of primitive type variables. All variables have properties and "changed" events.
  There is a class (named Frame) which contains a lot of primitive type variables and also few variables of type WPoint, CPoint... and such. Again, all variables have properties and "changed" events including variables of type *Point.</p>
  
  <p>Finally, there is a class named FrameBox which is basically a WinForm-Control that contains a variable of type Frame (frame) and properties that gets/sets elements of the frame. FrameBox class have some *PointElement properties to simplify reaching some frequently needed data in frame. Likewise, it has *PointElementChanged events so one can connect them to event methods in designer.</p>
  
  <p><strong>Problem:</strong>
  All data needs to be fully accessible for other components to make the whole stuff going, and all system system blow up because I want to make event call-back to outer classes, here is an example:</p>
  
  <pre><code>frameBox.frame.wpoint.x = 4;
  </code></pre>
  
  <p>Above code is not only expected to call <code>frameBox.frame.wpoint.XChanged</code> event but also <code>frameBox.WPointXChanged</code> event. As the data needs to be modifiable we should be able to do <code>frameBox.frame = new Frame()</code> and <code>frameBox.frame.wpoint = new WPoint()</code>. Having one property and event for each field in Frame.* would be an overkill and not a solution as there are too many variables/events.</p>
  
  <p>Let's say we registered our events (to sub-class events) at the constructor of FrameBox <code>frameBox.frame.wpoint.XChanged += frameBox.WPointXChanged</code>, when a simple assign happens <code>frameBox.frame.wpoint = new WPoint()</code> we no longer have <code>frameBox.WPointXChanged</code> registered. I cannot force *Point constructor to get event parameters as I stated before there are too many events and it would result with code bloat.</p>
  
  <p>Looking forward for any help, thanks anyone for spending time on helping me solving this!..</p>