title: Binded WPF Rectangle.Fill is not updating when source is set for the first time
body: <p>I have a very primitive colorpicker tool (in WPF). Here's how it looks:</p>
  <p><img src="https://i.stack.imgur.com/ChWxn.jpg" alt="enter image description here" /></p>
  <p>As you can see, you can set the color by HSV or RGB on these very ugly sliders :) and the Fill property of the <code>Rectangle</code> gets updated.</p>
  <p>For reasons not to be discussed, this ColorPicker is a UserControl.</p>
  <p>It has truckloads of DependencyProperties (mostly for the color manipulation): Hue, Sat, Value, R,G,B; and the mixed colors of these values: RGBColor and HSVColor.</p>
  <p>Here's the culprit RGBColor:</p>
  <pre><code>public Color RGBColor
      {
          get { return (Color)GetValue(RGBColorProperty); }
          set { SetValue(RGBColorProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for RGBColor.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty RGBColorProperty =
          DependencyProperty.Register(&quot;RGBColor&quot;, typeof(Color), typeof(SimpleColorPicker), new UIPropertyMetadata(Colors.Transparent, (d, e) =&gt;
          {
              var colorpicker = d as SimpleColorPicker;
              if (e.NewValue != null &amp;&amp; colorpicker != null)
              {
                  
                  var c = (Color)e.NewValue;
  
                  if (c.R != colorpicker.R) colorpicker.R = c.R;
                  if (c.G != colorpicker.G) colorpicker.G = c.G;
                  if (c.B != colorpicker.B) colorpicker.B = c.B;
  
                  colorpicker.RGBBrush = new SolidColorBrush(colorpicker.RGBColor);
  
                  if (colorpicker._fromRGB)
                  {
                      var hsv = HSVColor.FromColor(c);
                      if (colorpicker.HSVColor == null || !colorpicker.HSVColor.Equals(hsv))
                          colorpicker.HSVColor = hsv;
                  }
  
                  colorpicker.forceDisplayRefresh();
              }
  
          }));
  </code></pre>
  <p>In the XAML part I use the following for getting the RGBColor to the Rectangle:</p>
  <pre><code>&lt;Rectangle Height=&quot;100&quot; x:Name=&quot;DisplayRectangle&quot;&gt;
      &lt;Rectangle.Fill&gt;
          &lt;SolidColorBrush Color=&quot;{Binding RGBColor, Mode=OneWay}&quot; /&gt;
      &lt;/Rectangle.Fill&gt;
  &lt;/Rectangle&gt;
  </code></pre>
  <p>(DataContext at this point is the control itself, because I didn't want to use FindAncestor on all the bindings, so  in the ColorPicker constructor I have <code>LayoutRoot.DataContext = this;</code> where LayoutRoot is the root Grid of the control.)</p>
  <p>I'm trying to use this control in View. I have a VM for the View that implements <code>INotifyPropertyChanged</code> and has a notify-property (is that how it's called?)</p>
  <pre><code>public Color Color
  {
      get { return _color; }
      set
      {
          _color = value;
          RaisePropertyChanged(() =&gt; Color);
      }
  }
  </code></pre>
  <p>I'd like to edit this property with the Colorpicker (DataContext is the VM):</p>
  <pre><code>&lt;base:SimpleColorPicker RGBColor=&quot;{Binding Color}&quot;/&gt;
  </code></pre>
  <p>The editing itself works. <code>Color</code> property gets set in the VM when I adjust the sliders on the colorpicker.</p>
  <p>However, when I load a VM that already has Color set, the <code>Rectangle</code> won't update. The sliders do, and all the <code>DependencyProperties</code> get set to the right value, but the Rectangle's Fill just won't change. (It stay <code>Transparent</code> which is the default value of the <code>RGBColor DependencyProperty</code>).
  (again, after loading, if I adjust the sliders, the Rectangle updates again...)</p>
  <p><strong>Things that have already failed:</strong></p>
  <ul>
  <li>I've tried using a Brush and bind the Fill property directly (instead
  of Fill.Color)</li>
  <li>I've tried directly updating the binding on
  Rectangle.Fill</li>
  </ul>
  <p>What more is there to try and make this work?</p>