title: Calendar Control Event Issues in WPF C#
body: <p>I'm trying to bind a TextBox to the selected date on a Calendar control, and when it initializes, there is no issue.  The problem is that after, when I change the selected date, the TextBox remains at its initial value (today).  I have tried 3 methods, including simply returning to TextBox.Text = Calendar.DisplayDate.ToString(), but the problem persists.  </p>
  
  <p>Does anybody know either what causes this, or a way around it?</p>
  
  <p>Note that PropertyChanged is not null in Method 2.</p>
  
  <p>My code is as follows, with the other two methods implemented:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Calendar Grid.Column="1" Height="170" HorizontalAlignment="Left" Name="calStart" VerticalAlignment="Top"  Width="180" IsTodayHighlighted="False" SelectedDatesChanged="CalStartSelectedDatesChanged"&gt;
              &lt;Calendar.CalendarDayButtonStyle&gt;
                  &lt;Style&gt;
                      &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Converter={StaticResource conv}}" Value="1"&gt;
                              &lt;Setter Property="Button.Background" Value="LightGreen" /&gt;
  
                          &lt;/DataTrigger&gt;
                  &lt;/Style.Triggers&gt;
                  &lt;/Style&gt;
              &lt;/Calendar.CalendarDayButtonStyle&gt;
       &lt;/Calendar&gt;
   &lt;TextBox Height="23" HorizontalAlignment="Left" Margin="34,33,0,0" Text="{Binding StartBindProp, Mode=OneWay}" Name="txtStartDate" VerticalAlignment="Top" Width="120" Grid.Column="1" Grid.Row="1" /&gt;
  </code></pre>
  
  <p>C#
  Method 1:</p>
  
  <pre><code>private void CalStartSelectedDatesChanged(object sender, SelectionChangedEventArgs e)
      {
          StartBindProp = calStart.DisplayDate.ToString();
      }
  
  
      public string StartBindProp
      {
          get { return (string)GetValue(StartBindPropProperty); }
          set { SetValue(StartBindPropProperty, value); }
      }
  
      // Using a DependencyProperty as the backing store for StartBindProp.  This enables animation, styling, binding, etc...
      public static readonly DependencyProperty StartBindPropProperty =
          DependencyProperty.Register("StartBindProp", typeof(string), typeof(MainControl), new UIPropertyMetadata(""));
  </code></pre>
  
  <p>Method 2:</p>
  
  <pre><code> private void CalEndSelectedDatesChanged(object sender, SelectionChangedEventArgs e)
      {
          EndBind = calEnd.DisplayDate.ToString();
      }
  
      private string m_EndBind = "endtest";
  
  
      public string EndBind
      {
          get { return m_EndBind; }
          set
          {
              m_EndBind = value;
  
              if (null != PropertyChanged)
              {
                  PropertyChanged(this, new PropertyChangedEventArgs("EndBind"));
              }
          }
      }
  </code></pre>
  
  <p>Thanks for the help!</p>
  
  <p>EDIT:
  The following xaml has the same issue (and apparently renders the calendar read-only):</p>
  
  <pre><code>&lt;TextBox Text="{Binding ElementName=calStart, Path=DisplayDate, Mode=OneWay}" /&gt;
  </code></pre>