title: c# MVVM wpf design passing data between viewmodel and view methods
body: <p>I am not sure if I am quite catching the idea behind the MVVM design specially regarding passing the data from <code>viewmodel</code> <code>-&gt;</code> <code>view</code> and vice versa.</p>
  
  <p>So for example let's say I have a model that has those properties (As simple as possible) :</p>
  
  <pre><code>public class User{
  
  public string username {get; set;}
  public string password {get; set;}
  }
  </code></pre>
  
  <p>and here's my <code>ViewModel</code> that has a login method:</p>
  
  <pre><code> // dependency injection
  private readonly Context _context;
  public constructor(Context context)
  {
      _context = context;
  }
  // my method to verify login:
  
  public async Task&lt;bool&gt; login(string username, string password)
  {
      // fetching data
      var user = await _context.Users.FirstOrDefaultAsync(p =&gt; p.username== username&amp;&amp; p.Password == password);
      return (user != null);
   }
  </code></pre>
  
  <p>so my question is: how should I deliver these methods to the view class?</p>
  
  <p>I usually just do this inside the <code>button_click()</code>:</p>
  
  <pre><code>Var viewmodel = new Viewmodels.User();
  login_state = viewmodel.login(email, password);
  </code></pre>
  
  <p>However I just feel this isn't the right way as it'd make the design very tightly coupled. How should I implement it?</p>