title: WPF Xaml Binding class instance using INotifyPropertyChanged
body: <p>I have a problem working with databinding in XAML.The problem is the following, I want update a label from an istance of my ExampleClass.
  I see two method but one of this not work.
  The first is (in example code label1): in your xaml.cs define a property that is your reference to an instance of ExampleClass and in your xaml simply write YourPropertyReferenceToExampleClass.PropertyName but it not work
  The second is simple (in example code label2), set dataContext for your label to an istance of ExampleClass and in your xaml simply write PropertyName.</p>
  
  <p>Below the code (Xaml):</p>
  
  <pre><code>&lt;Window x:Class="SimpleBinding.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:SimpleBinding"
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Title="MainWindow" Height="137.03" Width="255.263"&gt;
  &lt;Grid&gt;
      &lt;Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="45,76,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/&gt;
      &lt;Label x:Name="label" Content="{Binding One}" HorizontalAlignment="Left" Margin="10,14,0,0" VerticalAlignment="Top"/&gt;
      &lt;Label x:Name="label1" Content="{Binding T.Name}" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top"/&gt;
      &lt;Label x:Name="label2" Content="{Binding Name}" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top"/&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Below the code (Xaml.cs):</p>
  
  <pre><code>using System.ComponentModel;
  using System.Windows;
  
  namespace SimpleBinding
  {
      public partial class MainWindow : Window, INotifyPropertyChanged
      {
          public event PropertyChangedEventHandler PropertyChanged;
          protected virtual void OnPropertyChanged(string propertyName)
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
  
          private string _one;
          public string One
          {
              get =&gt; _one; set
              {
                  _one = value;
                  OnPropertyChanged("One");
              }
          }
  
          public ExampleClass T { get; private set; }
  
          public MainWindow()
          {
              InitializeComponent();
          }
  
          private void Button_Click(object sender, RoutedEventArgs e)
          {
              One = "ciao";
              T = new ExampleClass();
              label2.DataContext = T;
              T.Name = "foo";
          }
      }
  }
  </code></pre>
  
  <p>Below the code (ExampleClass.cs):</p>
  
  <pre><code>using System.ComponentModel;
  
  namespace SimpleBinding
  {
      public class ExampleClass : INotifyPropertyChanged
      {
          private string _name;
  
          public string Name
          {
              get
              {
                  return _name;
              }
  
              set
              {
                  if (_name == value) return;
  
                  _name = value;
                  OnPropertyChanged("Name");
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
          protected virtual void OnPropertyChanged(string propertyName)
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p>How the first method should work?</p>