title: MVVM CallerMemberName and "magic strings"
body: <p>New C# 5.0 release introduced something to get rid of "magic strings" in INotifyPropertyChanged implementation like:</p>
  
  <pre><code>OnPropertyChanged("CustomerName");
  </code></pre>
  
  <p>Now it is possible to write just:</p>
  
  <pre><code>OnPropertyChanged();
  </code></pre>
  
  <p>It is possible due to CallerMemberName in method definition:</p>
  
  <pre><code>protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
  { ... }
  </code></pre>
  
  <p>It is much more refactoring friendly than "magic strings" way and faster than lambda expressions, but I wonder how can we call multiple times OnPropertyChanged from one set accessor. For example if we wanted something like this:</p>
  
  <pre><code>public int Width
  {
      get
      {
          return width;
      }
      set
      {
          width = value;
          OnPropertyChanged("Width");
          OnPropertyChanged("Height");
      }
  }
  </code></pre>
  
  <p>How can we do this with CallerMemberName way and avoid using "magic strings" and lambda expressions?</p>
  
  <p>I also wonder how can we avoid using "magic strings" in IDataError info:</p>
  
  <pre><code>public string Error
          {
              get;
              private set;
          }
  
          public string this[string columnName]
          {
              get
              {
                  if (columnName == "Name")
                  {
                      if (String.IsNullOrWhiteSpace(Name))
                          Error = "Name cannot be null or empty.";
                      else
                          Error = null;
                  }
  
                  return Error;
              }
          }
  </code></pre>
  
  <p>I am new to MVVM so maybe I overlooked some clever way to deal with "magic strings", however I did some research and found nothing.</p>