title: Implementing textbox lostfocus event in MVVM
body: <p>I want to accomplish a simple task.
  Need to implement textbox lostfocus, As the user puts in data, as soon as one field is filled and he reaches on to the next, it should fire a validation function on the previous field.
  Also, I am using MVVM pattern.</p>
  
  <p>So I have this class</p>
  
  <pre><code>public class data : INotifyPropertyChanged
  {
  
      public string name;
      public string Name
      {
          get
          {
              return name;
          }
  
          set
          {
              name = value;
              OnPropertyChanged("Name");
          }
      }
      public string firstname;
      public string FirstName
      {
          get
          {
              return firstname;
          }
  
          set
          {
              firstname = value;
              OnPropertyChanged("FirstName");
          }
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
      private void OnPropertyChanged(string propertyName)
      {
          if (this.PropertyChanged != null)
          {
              // Raise the PropertyChanged event
              this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  } 
  </code></pre>
  
  <p>In the Viewmodel I got this</p>
  
  <pre><code>data1 = new data() { name = "Eddie Vedder", firstname = "Eddie" }; //this line in initialization 
  public data _data1;
  public data data1
  {
      get { return _data1; }
      set 
      {
  
          _data1 = value;
          ValidateThis();
          NotifyPropertyChanged(new PropertyChangedEventArgs("data1"));
      }
  }
  </code></pre>
  
  <p>In Xaml:</p>
  
  <pre><code>&lt;StackPanel Orientation="Horizontal" &gt;
      &lt;Label Width="90" Content="Name" Height="28" HorizontalAlignment="Left" Name="lblName" VerticalAlignment="Top" /&gt;
      &lt;TextBox Text="{Binding Path=data1.name, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"   MaxLength="40" TabIndex="2" Height="25" Margin="0,3,0,0" HorizontalAlignment="Left" Name="txtName" VerticalAlignment="Top" Width="200" /&gt;
  &lt;/StackPanel&gt;
  &lt;StackPanel Orientation="Horizontal" &gt;
      &lt;Label Width="90" Content="First Name" Height="28" HorizontalAlignment="Left" Name="lblFirstName" VerticalAlignment="Top" /&gt;
      &lt;TextBox Text="{Binding  Path=data1.firstname, UpdateSourceTrigger=LostFocus, Mode=TwoWay}" MaxLength="40" TabIndex="3" Name="txtFirstName" Height="25" Margin="0,3,0,0" VerticalAlignment="Top" Width="200" &gt;
      &lt;/TextBox&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>My binding is working as it shoes the default name Eddie Vedder when I execute it.
  When I debug it, it doesn't enter the class data.</p>