title: How to implement dependency object/property on custom class?
body: <p>Here is my Person Class:</p>
  
  <pre><code>    public class Person
  {
      private string _lastName;
  
      public string LastName
      {
          get { return _lastName; }
          set { _lastName = value; }
  
      }
  }//close class
  </code></pre>
  
  <p>Here is my XAML:</p>
  
  <pre><code>        &lt;StackPanel&gt;
          &lt;TextBox x:Name="txtLastName" 
                   Height="50" Width="300"
                   DataContext="{Binding ElementName=_this, Path=PersonObject}" 
                   Text="{Binding Path=LastName}" /&gt;
  
          &lt;Button Height="50" Width="100" x:Name="btnChangeValue" Content="Change Value" Click="btnChangeValue_Click"/&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Here is my XAML.CS</p>
  
  <pre><code>public partial class ClassDependency : Window
  {
      public Person objPerson = new Person();
      public ClassDependency()
      {
          objPerson.LastName = "testing...";
          InitializeComponent();
  
      }
  
      public Person PersonObject
      {
          get { return objPerson; }
          set { objPerson = value; }
      }
  
      private void btnChangeValue_Click(object sender, RoutedEventArgs e)
      {
          objPerson.LastName = "New value after click....";
      }
  }//close class
  </code></pre>
  
  <p>My question is: After clicking "btnChangeValue" it does changing Last Name in my code behind but it is not reflection my textbox "txtLastName". How can I fix this??? Should I implement Dependency Property in my xaml.cs file?? I tried that too but no use.</p>
  
  <pre><code>    public static readonly DependencyProperty PersonObjectProperty = DependencyProperty.Register("PersonObject", typeof(object), typeof(ClassDependency));
      public Person PersonObject
      {
          get { return (Person)GetValue(PersonObjectProperty); }
          set { SetValue(PersonObjectProperty, value); }
      }
  </code></pre>
  
  <p>What should I do?? Please advice..</p>