title: Does calling View Model methods in Code Behind events break the MVVM?
body: <p>I wonder if that would break the MVVM pattern and, if so, why and why is it so bad?</p>
  
  <p><strong>WPF:</strong></p>
  
  <pre><code>&lt;Button Click="Button_Click" /&gt;
  </code></pre>
  
  <p><strong>Code Behind:</strong></p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
      ViewModel.CallMethod();
  }
  </code></pre>
  
  <p><strong>View Model:</strong></p>
  
  <pre><code>public void CallMethod()
  {
      // Some code
  }
  </code></pre>
  
  <p>IMHO, it keeps the code behind quite simple, the view model is still agnostic about the view and code behind and a change to the view doesn't affect the business logic.</p>
  
  <p>It seems to me more simple and clear than <code>Commands</code> or <code>CallMethodAction</code>.</p>
  
  <p>I don't want the kind of answer "it is not how it should be done". I need a proper and logical reason of why doing so could lead to maintenance or comprehension problems.</p>