title: WPF - Set Focus when a button is clicked - No Code Behind
body: <p>Is there a way to set <code>Focus</code> from one control to another using WPF <code>Trigger</code>s?</p>
  
  <p>Like the following example:</p>
  
  <pre><code>&lt;Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
    &lt;Grid&gt;  
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition/&gt;
        &lt;RowDefinition/&gt;
        &lt;RowDefinition/&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;TextBox Name="txtName"&gt;&lt;/TextBox&gt;    
      &lt;TextBox Grid.Row="1" Name="txtAddress"&gt;&lt;/TextBox&gt;
      &lt;Button Grid.Row="2" Content="Finish"&gt;
          &lt;Button.Triggers&gt;
              &lt;EventTrigger RoutedEvent="Button.Click"&gt;
  
                  &lt;!-- Insert cool code here--&gt;  
  
              &lt;/EventTrigger&gt;
          &lt;/Button.Triggers&gt;
      &lt;/Button&gt;
    &lt;/Grid&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>Is there a way for this <code>EventTrigger</code> to put to focus on the textBox "txtName"?</p>
  
  <p>I am trying to find the way to do something like this using strict MVVM.  If this is something that should not be done via the XAML (in MVVM) then that is fine.  But I would like to see some kind of documentation as to how it fit in the MVVM pattern doing it outside the XAML.</p>