title: How to add a "MouseClicked" behavior to a WPF Style
body: <p>So I have this WPF style:</p>
  
  <pre><code>&lt;Style x:Key="SmallLinkButton" TargetType="Button"&gt;
  &lt;Setter Property="Template"&gt;
      &lt;Setter.Value&gt;
          &lt;ControlTemplate TargetType="Button"&gt;
              &lt;TextBlock TextDecorations="Underline"&gt;
                  &lt;ContentPresenter /&gt;
              &lt;/TextBlock&gt;
          &lt;/ControlTemplate&gt;
      &lt;/Setter.Value&gt;
  &lt;/Setter&gt;
      &lt;Setter Property="Foreground" Value="#234D20" /&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="IsMouseOver" Value="true"&gt;
              &lt;Setter Property="Foreground" Value="#77AB59" /&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>To make a link button wich turns its color when the mouse is over. And I have a set of buttons with this style, I want to be able to, once the user has clicked the mouse, change the button foreground to the second value, unless he clicks another button.</p>
  
  <p>It is posible to do this just by using the style? I don't believe it, but I'm novice with WPF or, how would you implement this feature. </p>
  
  <p>Thanks in advance. </p>
  
  <p><strong>Solution</strong></p>
  
  <p>As suggested by @Phil, the solution was to use a container, a listbox in this case, styled as:</p>
  
  <pre><code>&lt;!-- Start of the menu --&gt;
      &lt;!-- Horizontal listbox--&gt;
      &lt;Style x:Key="MenuListBox" TargetType="ListBox"&gt;
          &lt;Setter Property="BorderBrush" Value="{x:Null}" /&gt;
          &lt;Setter Property="ItemsPanel"&gt;
              &lt;Setter.Value&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;StackPanel Orientation="Horizontal" /&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;!-- Listbox item with the special behavior --&gt;
      &lt;Style x:Key="MenuListBoxItem" TargetType="ListBoxItem"&gt;
          &lt;Style.Resources&gt;
              &lt;!-- SelectedItem with focus --&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                  Color="Transparent" /&gt;
              &lt;!-- SelectedItem without focus --&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" 
                  Color="Transparent" /&gt;
              &lt;!-- SelectedItem text foreground --&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" 
                  Color="{DynamicResource {x:Static SystemColors.ControlTextColorKey}}" /&gt;
          &lt;/Style.Resources&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
      &lt;/Style&gt;
      &lt;!-- Menu buttons --&gt;
      &lt;Style x:Key="BigMenuLinkButton" TargetType="TextBlock"&gt;
          &lt;Setter Property="FontFamily" Value="Segoe UI Light"/&gt;
          &lt;Setter Property="FontSize" Value="36" /&gt;
          &lt;Setter Property="Foreground" Value="#C9DF8A" /&gt;
  
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsMouseOver" Value="true"&gt;
                  &lt;Setter Property="Foreground" Value="#77AB59" /&gt;
              &lt;/Trigger&gt;
              &lt;DataTrigger Value="True" Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}}"&gt;
                  &lt;Setter Property="Foreground" Value="#234D20"/&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
      &lt;Style x:Key="MediumMenuLinkButton" TargetType="TextBlock"&gt;
          &lt;Setter Property="FontSize" Value="24" /&gt;
          &lt;Setter Property="Foreground" Value="#C9DF8A" /&gt;
  
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsMouseOver" Value="true"&gt;
                  &lt;Setter Property="Foreground" Value="#77AB59" /&gt;
              &lt;/Trigger&gt;
              &lt;DataTrigger Value="True" Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}}"&gt;
                  &lt;Setter Property="Foreground" Value="#234D20"/&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
      &lt;!-- End of the menu --&gt;
  </code></pre>