title: Change in dependency property from code is not displayed
body: <p>I've created a button, which is supposed to support wordwrapping. My XAML code for the button looks like this:</p>
  
  <pre><code>&lt;Button x:Class="POS.TouchScreen.UI.Elements.TouchButtonWPF"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" Height="23" HorizontalAlignment="Left" Name="buttonGrid" VerticalAlignment="Top" Width="75" BorderBrush="#FF8A97A9" Margin="4"
               DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt;
      &lt;TextBlock Name="ButtonTextBlock" 
                 HorizontalAlignment="Stretch" 
                 VerticalAlignment="Stretch"
                 Text="{Binding ButtonText, Mode=TwoWay}"
                 TextWrapping="Wrap"&gt;
      &lt;/TextBlock&gt; 
  &lt;/Button&gt;
  </code></pre>
  
  <p>I've implemented the property as shown below:</p>
  
  <pre><code>public static readonly DependencyProperty ButtonTextProperty = 
      DependencyProperty.Register("ButtonText", typeof(string), typeof(TouchButtonWPF), new UIPropertyMetadata("Button",new PropertyChangedCallback(OnButtonTextChanged), new CoerceValueCallback(OnCoerceButtonText)));
  
  private static object OnCoerceButtonText(DependencyObject o, object value)
  {
      TouchButtonWPF button = o as TouchButtonWPF;
      if (button != null)
          return button.OnCoerceButtonText((string)value);
      else 
          return value;
  }
  
  protected virtual string OnCoerceButtonText(string value)
  {
      return value;
  }
  
  private static void OnButtonTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
  {
      TouchButtonWPF button = o as TouchButtonWPF;
      if (button != null)
          button.OnButtonTextChanged((string)e.NewValue, (string) e.OldValue);
  }
  
  protected virtual void OnButtonTextChanged(string NewValue, string OldValue)
  {
      this.ButtonTextBlock.Text = NewValue;
  }        
  
  public string ButtonText
  {
      get { return (string)GetValue(ButtonTextProperty); }
      set { SetValue(ButtonTextProperty, value); }
  }
  </code></pre>
  
  <p>Inserting an instance of the TouchButtonWPF looks like this</p>
  
  <pre><code>&lt;tse:TouchButtonWPF ButtonText="OK" FontSize="16" Height="77" HorizontalAlignment="Left"x:Name="buttonOk" Width="85" /&gt;                
  </code></pre>
  
  <p>This works perfectly and the button text appears correctly. However when i assign the ButtonText from C# code, the text is not updated. I'm assigning the variable as shown below.</p>
  
  <pre><code> touchButton.ButtonText = navButton.Caption;
  </code></pre>
  
  <p>Can anybody tell me what I'm doing wrong? 
  Note that the event handlers have been implemented when it didn't work initially, can't figure out if these eventhandlers are needed at all for the functionality i try to attain?</p>
  
  <p>Look forward to read your replies :)</p>