title: MVVM INotifyPropertyChanged with Automatic Property Name implementation
body: <p>From my understanding, we can use the INofityProperty in a MVVM style application with code similar to the following</p>
  
  
  
  <pre class="lang-c# prettyprint-override"><code>    object _SelectedPerson;
      public object SelectedPerson
      {
          get
          {
              return _SelectedPerson;
          }
          set
          {
              if (_SelectedPerson != value)
              {
                  _SelectedPerson = value;
                  RaisePropertyChanged("SelectedPerson");
              }
          }
      }
  </code></pre>
  
  <p>Now, I've seen <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx" rel="nofollow">Josh Smith's excellent example</a> where he implements extra code to capture what happens if the developer types in a Property name which isn't recognized, such as a typo!</p>
  
  <p>Please tell me if you hate this, but there is a way to get the method name from the stack trace. So, we could instead implement something like</p>
  
  <pre class="lang-c# prettyprint-override"><code>    object _SelectedPerson;
      public object SelectedPerson
      {
          get
          {
              return _SelectedPerson;
          }
          set
          {
              if (_SelectedPerson != value)
              {
                  _SelectedPerson = value;
                  RaisePropertyChanged(Current.Method);
              }
          }
      }
  
  static class Current
  {
      public static string Method()
      {
          StackTrace st = new StackTrace();
          return (st.GetFrame(1).GetMethod().Name.Split('_')[1]);            
      }
  }
  </code></pre>
  
  <p>I can only assume this will always work since the the RaisePropertyChanged event always occurs in the Setter (and if I'm wrong, please do correct me). </p>
  
  <p>Now please note, I'm not in a position to really try this, in that at work (where I can work on bigger projects) I'm still on .NET 2.0 and so WPF/MVVM is a long way off in the future but I'm learning in my own time. </p>
  
  <p>So, my question is from those who have used it, is it really better to have an approach which alerts the user of the error compared to removing the option for the error (or do you feel I've miss-understood something); the thing is, Josh Smith is recognized, an expert in this field, and so if he suggests that approach then normally I'd follow blindly but in this case I can't help but quiz it and feel the need to understand more.</p>