title: DependencyProperty and DataBinding - Why property setter isn't called when UserControl loads?
body: <p>I want to model the behavior of a <code>RangeSlider</code>, using a class <code>RangeSliderModel</code> with properties describing the sizes (widths) for a given set of values.</p>
  
  <p>Then, I created an UserControl where the position and size of some rectangles should represent those properties, and some instances of <code>Thumb</code> from which the <code>DragDelta</code> events are used to resize these rectangles and enable the calculation of a new value for a <code>RangeSliderModel</code>.</p>
  
  <p>At last, this UserControl has a  <code>DependencyProperty</code> of type <code>RangeSliderModel</code>:</p>
  
  <pre><code>    public RangeSliderModel Model
      {
          get
          {
              return (RangeSliderModel)GetValue(RangeSliderModelProperty);
              // or instead calculate a RangeSliderModel from children sizes.
          }
          set
          {
              // this IS NOT called when UserControl loads
              SetValue(RangeSliderModelProperty, value);
              // here I could take the value and calculate new sizes for the children.
          }
      }
  
      public static readonly DependencyProperty RangeSliderModelProperty =
          DependencyProperty.Register("RangeSliderModel",
                                      typeof(RangeSliderModel),
                                      typeof(MyUserControl),
                                      new PropertyMetadata(ModelPropertyChanged));
  
      private static void ModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
      {
          // this IS called when UserControl loads.
          RangeSliderModel model = e.NewValue as RangeSliderModel;
      }
  </code></pre>
  
  <p>I was expecting to override the <code>SetValue</code> and <code>GetValue</code> properties, but even when I bind this DependencyProperty to a corresponding Source in ViewModel, the setter is never called! And I can't quite understand why PropertyChangedHandler is called instead, and much less what I should do with this information - I was expecting to use just <code>GetValue</code> and <code>SetValue</code> in a way similar to a ValueConverter.</p>