title: Change button background color due to events and view model property
body: <p>I have a button that can be at <strong>one</strong> of three modes:</p>
  
  <ul>
  <li>Normal - No mouse hover and not selected</li>
  <li>Hover - Mouse hover and not selected</li>
  <li>Selected - A property at the view model (DataContext) called IsSelected equals true</li>
  </ul>
  
  <p>This is my current code:</p>
  
  <pre><code>&lt;Style x:Key="FlatButtonStyle" TargetType="Button"&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                  &lt;Setter Property="Background" Value="Orange"/&gt;
              &lt;/Trigger&gt;
              &lt;DataTrigger Binding="{Binding IsSelected}"&gt;
                  &lt;Setter Property="Background" Value="Yellow"/&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
          &lt;Setter Property="Background" Value="Gray" /&gt;           
          &lt;Setter Property="Foreground" Value="White"/&gt;
          &lt;Setter Property="Width" Value="125"/&gt;
          &lt;Setter Property="Height" Value="35"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Button"&gt;
                      &lt;Border BorderThickness="0"
                              Background="{TemplateBinding Background}"
                              CornerRadius="12"&gt;
                 &lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
                      &lt;/Border&gt;
                      &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
  &lt;/Style&gt;    
  </code></pre>
  
  <p>However, only the Hover and normal states work.
  I tried data triggers, visual state manager but I'm new to WPF and couldn't make it work.</p>