title: Handling a Button's Click event in XAML?
body: <p>This feels like a terribly basic question but I am sure there is a better way to do this. I have a <code>Button</code> in my UI which selects a specific tab and fire a <code>Command</code> from the <code>ViewModel</code></p>
  
  <p>Here is the current code (which works fine):</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Button Content="Button!" Click="OnButtonClick" Command="{Binding WhateverCommand}" /&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>private void OnButtonClick(object sender, RoutedEventArgs e)
  {
       theTab.IsSelected = true;
  }
  </code></pre>
  
  <p>Isn't there any cleaner, XAML-only way to do that UI operation? I was thinking about something like:</p>
  
  <pre><code>&lt;Button Content="Button!" Click="OnButtonClick" Command="{Binding WhateverCommand}"&gt;
      &lt;Button.Triggers&gt;
          &lt;EventTrigger RoutedEvent="Click"&gt;
              &lt;Setter TargetName="theTab" Property="IsSelected" Value="True" /&gt;
          &lt;/EventTrigger&gt;
      &lt;/Button.Trigger&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p>But unfortunately it seems like the <code>EventTrigger</code> won't support a <code>Click</code> event. Why so? I am still sometimes confused with triggers after a few years working in WPF, and this pretty much sums it up. When trying to build that I have an error on the <code>Setter</code> line:</p>
  
  <pre><code>A value of type 'Setter' cannot be added to a collection or dictionary of type 'TriggerActionCollection'.
  </code></pre>
  
  <p>Thank you!</p>
  
  <p><strong>EDIT</strong> since I was ask the XAML structure of my Window, it looks like this:</p>
  
  <pre><code>&lt;DockPanel LastChildFill="True"&gt;
      &lt;Ribbon DockPanel.Dock="Top"&gt;
          &lt;Button Content="Button!" Click="OnButtonClick" Command="{Binding WhateverCommand}" /&gt;
      &lt;/Ribbon&gt;
      &lt;TabControl&gt;
          &lt;TabItem x:Name="theTab" /&gt;
      &lt;/TabControl&gt;
  &lt;/DockPanel&gt;
  </code></pre>