title: Subscribing to PropertyChanged of WCF service's DataContract proxy classe
body: <p>I like the idea of extending on the client side classes that are data contracts of WCF services using partial classes. But I encountered a problem that considerably spoils the party.</p>
  
  <p>Imagine on the server side I have a class:</p>
  
  <pre><code>[DataContract]
  public class SolidObject
  {
      [DataMember]
      public Point Position { get; set; }
      [DataMember]
      public Size Size { get; set; }
  }
  </code></pre>
  
  <p>On the client side I have a proxy class generated, which is used there in the business logic layer. According to the needs of the business logic I extend it this way:</p>
  
  <pre><code>public partial class SolidObject
  {
      public Rect Bounds { get { return new Rect(Position.X - Size.Width / 2, Position.Y - Size.Height / 2, Size.Width, Size.Height); }}
  }
  </code></pre>
  
  <p>Now I want to ensure that anytime either Position or Size changes, then Bounds chage event is invoked. It is easy to do by the code:</p>
  
  <pre><code>PropertyChanged += (sender, e) =&gt;
      {
          if ((e.PropertyName == "Position") || (e.PropertyName == "Size")) PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Bounds"));
      };
  </code></pre>
  
  <p>The question is where the good place to put this code in is.</p>
  
  <p>If objects weren't created by a service call, I'd put it into the constructor. But WCF services ignore constructors on the client side, see <a href="https://stackoverflow.com/questions/299441/constructor-not-showing-up-in-my-wcf-client-serialization-problem">constructor not showing up in my WCF client, serialization problem?</a>.</p>
  
  <p>Now, right after service response my program searches through data contract hierarchy, gets desired objects and adds event handlers. But I don't think it's a right thing.</p>
  
  <p>So I'm interesting in where to it is better to do or, maybe, reasoning that the whole approach should be changed. Any ideas appreciated.</p>