title: Databinding custom XML serializable Color class in C#
body: <p>I have a class, SerializableColor, to allow me to XML serialize Colors.</p>
  
  <pre><code>public class SerializableColor
  {
  
      // omitted constructors, etc. ...
  
      [XmlIgnore]
      public Color Color
      {
          get { return Color.FromArgb(this.Alpha, this.Red, this.Green, this.Blue); }
          set
          {
              this.Alpha = value.A;
              this.Red = value.R;
              this.Green = value.G;
              this.Blue = value.B;
          }
      }
  
      public int Alpha { get; set; }
      public int Red { get; set; }
      public int Green { get; set; }
      public int Blue { get; set; }
  }
  </code></pre>
  
  <p>Now, for example, consider a class Foo:</p>
  
  <pre><code>public class Foo 
  {
      public SerializableColor SColor { get; set; }
  }
  </code></pre>
  
  <p>I want to databind some WinForm Control properties to this class.
  When I first add the databinding, everything works fine, but any changes are not correctly propogated.</p>
  
  <p>For example, if I bind a Control's BackColor to SColor, the BackColor will be correctly updated, etc. However, if I then go and change the BackColor, the change will not be propogated to the Foo object's SColor. And if I change the Foo object's SColor, the change will not be seen on the Control's BackColor.</p>
  
  <p>Databinding to a plain Color property works as desired. Just not to a SerializableColor.</p>
  
  <p>Where am I going wrong?</p>