title: DataGrid WPF StackOverFlow Exception
body: <p>I am new to WPF and am having a problem with setting up binding to a <code>DataGrid</code>. My issue is that I keep getting a <code>StackOverFlowException</code> and the debugger breaks on the set statement of the <code>FirstName</code> property. I have referred to the follow resources and was unable to solve my problem:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms752347%28v=vs.110%29.aspx" rel="nofollow noreferrer">msdn databinding overview</a><br>
  <a href="https://stackoverflow.com/questions/13142600/stackoverflow-with-wpf-calendar-when-using-displaydatestart-binding">stackoverflow-with-wpf-calendar-when-using-displaydatestart-binding</a><br>
  <a href="https://stackoverflow.com/questions/14152222/how-to-get-rid-of-stackoverflow-exception-in-datacontext-initializecomponent">how-to-get-rid-of-stackoverflow-exception-in-datacontext-initializecomponent</a>  </p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>My code is:</p>
  
  <pre><code>namespace BindingTest
  {
    public partial class MainWindow : Window
    {
      public MainWindow()
      {
        InitializeComponent();
  
        ObservableCollection&lt;Person&gt; persons = new ObservableCollection&lt;Person&gt;()
        {
           new Person(){FirstName="john", LastName="smith"},
           new Person(){FirstName="foo", LastName="bar"}
        };
  
        dataGrid1.ItemsSource = persons;
      }
  
      class Person : INotifyPropertyChanged
      {
        public string FirstName
        {
          get
          {
            return FirstName;
          }
  
          set
          {
            FirstName = value;
            NotifyPropertyChanged("FirstName");
          }
        }
  
        public string LastName
        {
          get
          {
            return LastName;
          }
  
          set
          {
            LastName = value;
            NotifyPropertyChanged("LastName");
          }
        }
  
        public event PropertyChangedEventHandler PropertyChanged;
  
        private void NotifyPropertyChanged(String propertyName)
        {
          var handler = PropertyChanged;
          if (handler != null)
          {
            handler(this, new PropertyChangedEventArgs(propertyName));
          }
        }
      }
    }
  }
  </code></pre>
  
  <p><strong><code>Note about answer</code></strong></p>
  
  <p>For information about the recursion with property settings for anyone else who has the same issue, pleasee see this:</p>
  
  <p><a href="https://stackoverflow.com/questions/7063827/why-would-this-simple-code-cause-a-stack-overflow-exception">Why would this simple code cause a stack overflow exception?</a></p>