title: WPF & MVVM: Get values from textboxes and send it to ViewModel
body: <p>I'm trying to get the value of two Texboxes (I'm simulating a login window) when I press a button. The command assigned in the button fires correctly, but I don't know how to get the value of the textboxes to do the "login".</p>
  
  <p>This is my ViewModel:</p>
  
  <pre><code>class LoginViewModel : BaseViewModel
  {   
      public LoginViewModel()
      {
  
      }
  
      private DelegateCommand loginCommand;
      public ICommand LoginCommand
      {
          get
          {
              if (loginCommand == null)
                  loginCommand = new DelegateCommand(new Action(LoginExecuted),
                                 new Func&lt;bool&gt;(LoginCanExecute));
                  return loginCommand;
              }
          } 
  
      public bool LoginCanExecute()
      {
          //Basic strings validation...
          return true;
      }
      public void LoginExecuted()
      {
          //Do the validation with the Database.
          System.Windows.MessageBox.Show("OK");
      } 
  }
  </code></pre>
  
  <p>This is the view:</p>
  
  <pre><code> &lt;Grid DataContext="{StaticResource LoginViewModel}"&gt;
  
              &lt;TextBox x:Name="LoginTxtBox" HorizontalAlignment="Left" Height="23" Margin="34,62,0,0" Width="154" /&gt;
              &lt;PasswordBox x:Name="PasswordTxtBox" HorizontalAlignment="Left" Height="23" Margin="34,104,0,0" Width="154"/&gt;
              &lt;Button x:Name="btnAccept"
              HorizontalAlignment="Left" 
              Margin="34,153,0,0" 
              Width="108" 
              Content="{DynamicResource acceptBtn}" Height="31" BorderThickness="3"
              Command="{Binding LoginCommand}"/&gt;
  </code></pre>
  
  <p>If somebody can help...I'll be infinitely grateful.</p>