title: usercontrol with button content binding
body: <p>I have a usercontrol that I want to reuse but I can't seem to find a way how to change the button's content. I jave already tried everything I have searched in here. If somebody can tell me what is missing , I would really appreciate it as I have been trying to figure this out all day. here is my code:</p>
  
  <pre><code>    &lt;UserControl x:Class="SamplePopupWPF.UserControl1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Height="300" Width="300"&gt;
  &lt;Grid&gt;
      &lt;StackPanel&gt;
          &lt;Button x:Uid="btnLeft" Name="btnBindCmd" Height="23" Click="AddCommand" Content="{Binding ContentText, Mode=TwoWay}", DataContext="UserControl1"/&gt;
  
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Code for user control:</p>
  
  <pre><code> public string ContentText
      {
          get { return (string) GetValue(ContentTextProperty);  }
          set { SetValue(ContentTextProperty, value); }
      }
  
    public static readonly DependencyProperty ContentTextProperty = DependencyProperty.Register("ContentText",     typeof (String),  typeof (UserControl1),new IPropertyMetadata(String.Empty,textChangedCallback));
  
      static void textChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
      {
  
          UserControl1 c = (UserControl1) d;
          c.ContentText = e.NewValue as String;
     }
  </code></pre>
  
  <p>here is the Somepage using the control:"</p>
  
  <pre><code>    &lt;Grid &gt;
              &lt;user:UserControl1 x:Name="btnTEST" AddCommandClick="onBtnClick" ContentText="{Binding OtherCmd, ElementName=UserControl1}" /&gt;
  
      &lt;/Grid&gt;
  </code></pre>
  
  <p>code for Somepage using the control:</p>
  
  <pre><code>public string OtherCmd
      {
  
          get { return _otherCmd; }
          set
          {
              _otherCmd = value;
              //if (this.PropertyChanged != null)
                  NotifyProperty("OtherCmd");
  
          }
      }
  
   private void Window_Loaded(object sender, RoutedEventArgs e)
      {
              OtherCmd = "helloTest";
      }
  
   public event PropertyChangedEventHandler PropertyChanged;
      private void NotifyProperty(string propertyName)
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  </code></pre>
  
  <p>At some point I have not used all codes I placed above but still not working. Please help. thanks.</p>