title: PropertyChangeCallBack not firing on DependencyProperty in a UserControl
body: <p>Stumped : I am in the initial stages of creating a month planner control that need to carry out some UI action I The control when supplying a date from the ViewModel bound in XAML. When I run the code, the ViewModel does return the value but the PropertyChangeCallBack is not firing. I have done exactly the same thing in an <code>public class ExtendedDataGrid : DataGrid</code> control and that work fine but it is almost like you have to do something different with UserControls. Here is the basis of my code:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>public partial class DiaryMonthViewUserControl : UserControl
  {
      private DateTime _topDate;
  
  
      public DiaryMonthViewUserControl()
      {
          InitializeComponent();
      }
  
      // Property to get the date from the ViewModel for processing. This will fire and event to set the month we want to display
      public static readonly DependencyProperty TheDateProperty = DependencyProperty.Register("TheDate", typeof(DateTime),
                        typeof(DiaryMonthViewUserControl),
                        new FrameworkPropertyMetadata(DateTime.Today, OnDatePropertyChanged, null));
  
      public void SetTheCurrentDate(DateTime CurrentDate)
      {
          _topDate = CurrentDate;
  
          // Like Outlook, whatever date we supply, I want the first top level displayed date for the month
          if (_topDate.Day &gt; 1)
              _topDate = _topDate.AddDays(-(_topDate.Day-1)); // First day of the month
  
          // Get to the first Monday before the 1st of the month if not on a Monday
          while (_topDate.DayOfWeek != DayOfWeek.Monday)
              _topDate = _topDate.AddDays(-1);
  
          // I will set the UI here once I have solved this problem.
          MakeChangesToTheUIPlease();
      }
  
      private static void OnDatePropertyChanged(DependencyObject Source, DependencyPropertyChangedEventArgs e)
      {
          var control = Source as DiaryMonthViewUserControl;
  
          if (control != null)
              control.SetTheCurrentDate((DateTime)e.NewValue);
      }
  
      [Bindable(true)]
      public DateTime TheDate
      {
          get { return (DateTime)GetValue(TheDateProperty); }
          set { SetValue(TheDateProperty, value); }
      }
  }
  </code></pre>
  
  <p>I have also tried using <code>new PropertyChangedCallback(OnDatePropertyChanged)</code> as a parameter and that still does not work.</p>
  
  <p>My binding is as follows:</p>
  
  <pre><code>&lt;my:DiaryMonthViewUserControl HorizontalAlignment="Left" Margin="12,12,0,0" x:Name="diaryMonthViewUserControl1" 
                                VerticalAlignment="Top" Height="325" Width="476" TheDate="{Binding Path=CurrentDate}" /&gt;
  </code></pre>
  
  <p>When I run the code my ViewModel breaks on the getter for CurrentDate and if I remove the CurrentDate binding then it does not. The problem is that the call back is not firing and, for the life of me, I cannot fathom why.</p>
  
  <p>Any help would be much appreciated, particularly links to articles that may cover this problem.</p>