title: Xamarin Mac KVO model bindings - change fires twice
body: <p>I am trying to implement KVO bindings in a Xamarin Mac desktop app.
  I have followed the docs, and it is working, but the bindings appear to trigger 2 change events each time!</p>
  
  <p>If I create a KVO model with a binding like this...</p>
  
  <pre><code>    private int _MyVal;
      [Export("MyVal")]
      public int MyVal 
      { 
          get { return _MyVal; }
          set 
          { 
              WillChangeValue("MyVal"); 
              this._MyVal = value; 
              DidChangeValue("MyVal"); 
          }
      }
  </code></pre>
  
  <p>And bind a control to it in Xcode under the <code>bindings</code> section with the path <code>self.SettingsModel.MyValue</code></p>
  
  <p>It all appears to work fine, the control shows the model value, changing the model value programmatically updates the control and changing the control updates the model value.</p>
  
  <p>However, it runs the change event twice.  </p>
  
  <p>I am listening to the change so I can then hit an API with the value.</p>
  
  <pre><code>SettingsModel.AddObserver(this, (NSString)key, NSKeyValueObservingOptions.New, this.Handle);
  </code></pre>
  
  <p>Then later...</p>
  
  <pre><code> public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
      {
          switch (keyPath)
          {
              case "MyValue":
  
              // CODE HERE THAT UPDATES AN API WITH THE VALUE                 
              // But this handler fires twice.
  
  
              break;
          }
      }
  </code></pre>
  
  <p>Im not sure if its Xamarin or XCode that is causing the double trigger.</p>
  
  <p>Interestingly, if you don't specify the Xcode <code>WillChangeValue</code> and <code>DidChangeValue</code> methods, then it doesn't trigger twice - as though Xamarin has automatically triggered the change once.  However, it no longer triggers a change when programmatically updating the model value...</p>
  
  <pre><code>[Export("MyVal")]
  public int MyVal { get; set }
  </code></pre>
  
  <p>The above will work for the Xcode controls, they will update the model and trigger a change event.</p>
  
  <p>But programmatically updating it </p>
  
  <pre><code>this.SettingsModel.MyVal = 1;
  </code></pre>
  
  <p>Does not trigger the change event.</p>
  
  <p>It's very confusing, any idea on how to stop 2 change events firing, as I don't want to hit the API twice every time!</p>
  
  <p>When it fires twice, the stack trace (abridged) for the first has...</p>
  
  <pre><code>MainViewController.ObserveValue
  ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr()
  Foundation.NSObject.DidChangeValue(string forKey)
  CameraSettingsModel.set_MyValue(int value)
  AppKit.NSApplication.NSApplicationMain() 
  AppKit.NSApplication.Main(string[] args) 
  MainClass.Main(string[] args) 
  </code></pre>
  
  <p>Which looks fine, but the second...</p>
  
  <pre><code>MainViewController.ObserveValue
  AppKit.NSApplication.NSApplicationMain()
  AppKit.NSApplication.Main(string[] args) 
  MainClass.Main(string[] args)
  </code></pre>
  
  <p>Has no mention of the Setting Model triggering the event</p>