title: WPF UserControl Binding
body: <p>I've been trying to find a solution to this problem, but I'm quite confused by the possible approaches I've found on the Internet. </p>
  
  <p>I have created a UserControl containing a slider for DateTime.</p>
  
  <pre><code>&lt;UserControl x:Name="root"&gt;
      &lt;Grid x:Name="gridPanel"&gt;
         &lt;Slider x:Name="slider" HorizontalAlignment="Left" VerticalAlignment="Top" Height="34" Width="479"
                      Minimum="{Binding ElementName=root, Path=Minimum, Converter={StaticResource ResourceKey=dateToDoubleConverter}}"
                      Maximum="{Binding ElementName=root, Path=Maximum, Converter={StaticResource ResourceKey=dateToDoubleConverter}}"
                      Value="{Binding ElementName=root, Path=Value, Converter={StaticResource ResourceKey=dateToDoubleConverter}}" /&gt;
          &lt;Label x:Name="lblStartTime" Content="{Binding ElementName=slider, Path=Minimum, Converter={StaticResource ResourceKey=doubleToStringConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,73,0,0" FontSize="10"/&gt;
          &lt;Label x:Name="lblStopTime" Content="{Binding ElementName=slider, Path=Maximum, Converter={StaticResource ResourceKey=doubleToStringConverter}}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,73,10,0" FontSize="10"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>      public SliderPanel() {
           InitializeComponent();
           gridPanel.DataContext = this;
        }
  
        #region Dependency Property - Minimum
        public DateTime Minimum {
           get { return (DateTime)GetValue(MinimumProperty); }
           set { SetValue(MinimumProperty, value); }
        }
  
        public static readonly DependencyProperty MinimumProperty =
            DependencyProperty.Register("Minimum", typeof(DateTime), typeof(SliderPanel), new UIPropertyMetadata(DateTime.Now));
        #endregion
  
        #region Dependency Property - Maximum
        public DateTime Maximum {
           get { return (DateTime)GetValue(MaximumProperty); }
           set { SetValue(MaximumProperty, value); }
        }
  
        public static readonly DependencyProperty MaximumProperty =
            DependencyProperty.Register("Maximum", typeof(DateTime), typeof(SliderPanel), new UIPropertyMetadata(DateTime.Now.AddDays(1)));
        #endregion
  
        #region Dependency Property - Value
        public DateTime Value {
           get { return (DateTime)GetValue(ValueProperty); }
           set { SetValue(ValueProperty, value); }
        }
  
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(DateTime), typeof(SliderPanel), new UIPropertyMetadata(DateTime.Now, new PropertyChangedCallback(OnValueChanged)));
  
        public static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
           SliderPanel sP = (SliderPanel)d;
           if (e.Property == SliderPanel.ValueProperty) {
              sP.slider.Value = ((DateTime)e.NewValue).Ticks;
           }
        }
        #endregion
  </code></pre>
  
  <p>In my main window, I use the UserControl and bind some properties via code, such as:</p>
  
  <pre><code>     System.Windows.Data.Binding bndPlayTime = new System.Windows.Data.Binding("CurrentPlayTime");
       bndPlayTime.Source = controller;
       bndPlayTime.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
       lblCurPlayTime.SetBinding(System.Windows.Controls.TextBox.TextProperty, bndPlayString);
       sliderPanel.SetBinding(SliderPanel.ValueProperty, bndPlayTime);
  </code></pre>
  
  <p>The Controller class implements INotifyPropertyChanged:</p>
  
  <pre><code>  public DateTime CurrentPlayTime {
       get {
          return currentPlayTime;
       }
  
       set {
          if (DateTime.Compare(currentPlayTime, value) != 0) {
             currentPlayTime = value;
             NotifyPropertyChanged("CurrentPlayTime");
          }
       }
    }
  
    public event PropertyChangedEventHandler PropertyChanged;
  
    private void NotifyPropertyChanged(string propertyName) {
       if (PropertyChanged != null)
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
  </code></pre>
  
  <p>The CurrentPlayTime property is constantly updated by a timer. Now I would like the slider to move accordingly. The binding to the label works. The label is updated on a regular basis. However, the binding to the dependency property of the UserControl does not cause the slider value to update (even though I have implemented a callback method). Am I missing something?</p>
  
  <p>Please bear with me, I'm very new to WPF. I'd really appreciate your help.</p>