title: WPF binding not applying to target after initialization
body: <p>I am trying to add Series binding to the Visifire graphing controls set. To this end i have created a SeriesSource dependency property of time <code>DataSeriesCollection</code>. This is bound in the front end using:  </p>
  
  <pre><code>`&lt;Chart SeriesSource={Binding Series} /&gt;`  
  </code></pre>
  
  <p><strong>Problem</strong><br>
  When the source changes, the validation callback is called. The value that is passed to this is the correct value, a populated <code>ObservableCollection&lt;something&gt;</code>. Immediately after the validate value is called, the CoerceValue callback is called by something, and the value that is sent to it is an EMPTY <code>ObservableCollection&lt;something&gt;</code>. Bounty will go to anyone who can:  </p>
  
  <ol>
  <li>Get the correct populated <code>ObservableCollection&lt;someting&gt;</code> passed to the CoerceValue callback OR</li>
  <li>Get the correct value being passed to the OnSeriesSourceChanged callback OR</li>
  <li>Explain to me how i can do any of the above :)</li>
  </ol>
  
  <p>Here is the data template for the view:  </p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type vm:ReportViewModel}"&gt;
      &lt;Grid Name="rootGrid"&gt;
      &lt;visifire:Chart Grid.Row="1" SeriesSource="{Binding Series}"&gt;
          &lt;visifire:Chart.AxesX&gt;
                  &lt;visifire:Axis Title="X axis" /&gt;
          &lt;/visifire:Chart.AxesX&gt;
          &lt;visifire:Chart.AxesY&gt;
                  &lt;visifire:Axis Title="Y axis" /&gt;
          &lt;/visifire:Chart.AxesY&gt;
      &lt;/visifire:Chart&gt;
      &lt;/Grid&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>Here is the target Dependency Property</p>
  
  <pre><code>    //Getter and setter for Dependency Property
      public ObservableCollection&lt;DataSeries&gt; SeriesSource
      {
          get { return (ObservableCollection&lt;DataSeries&gt;)GetValue(SeriesSourceProperty); }
          set { SetValue(SeriesSourceProperty, value);           }
      }
  
      // Using a DependencyProperty as the backing store for SeriesSource.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty SeriesSourceProperty =
          DependencyProperty.Register("SeriesSource", typeof(ObservableCollection&lt;DataSeries&gt;), typeof(Chart), new UIPropertyMetadata(new ObservableCollection&lt;DataSeries&gt;(), new PropertyChangedCallback(OnSeriesSourceChange), new CoerceValueCallback(CoerceSeries)), new ValidateValueCallback(ValidateSeriesSource));
  
      //Value validation callback
      private static bool ValidateSeriesSource(object value)
      {
          if (value as ObservableCollection&lt;DataSeries&gt; != null)
              return true;
          return false;
      }
  
      //Dependency Property Changed callback
      private static void OnSeriesSourceChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
      {
          Chart c = d as Chart;
          if (c == null)
              return;
          //This line was causing the issue. It was overriding the setter
          c.SeriesSource = (DataSeriesCollection)e.NewValue;
      }
  
      //Coerce Value callback
      private static object CoerceSeries(DependencyObject d, object value)
      {
          Chart c = d as Chart;
          var collection = value as System.Collections.ObjectModel.ObservableCollection&lt;Visifire.Charts.DataSeries&gt;;
          foreach (var item in c.Series)
          {
              if (!collection.Contains(item))
                  c.Series.Remove(item);
          }
          foreach (var item in collection)
          {
              if (!c.Series.Contains(item))
                  c.Series.Add(item);
          }
          return collection;
      }
  </code></pre>
  
  <p><strong>New information</strong><br>
  The value being received by the CoerceValue callback is ALWAYS the first value which that property was set to. So if the first value i pass it is a list with 1 item, it will always coerce the value back to a list with one item!</p>
  
  <p>Edit: found the issue, it was in the property changed callback. Credit goes to Matt for helping me out with the CoerceValue callback</p>