title: How to set an event function via a style?
body: <p>I have several GUI control elements of which some are supposed to generate the same action (code-behind function call) on mouse interaction (MouseEnter, MouseLeave).<br>
  [edit] <em>I am performing some non style related functionality in my event handlers.</em><br>
  Right now I'm using event attributes in each control:</p>
  
  <pre><code>&lt;Button Name="Button" Content="Button 1" 
      MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave" 
      PreviewMouseDown="Button1_PreviewMouseDown" PreviewMouseUp="Button1_PreviewMouseUp" /&gt;
  &lt;Button Name="NotInteractingButton" Content="Button 2" 
      /&gt;&lt;!-- this button has no MouseOver-effects --&gt;
  &lt;ToggleButton Content="ToggleButton" 
      MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave"  /&gt;
  &lt;!-- needs to use IsMouseDirectlyOver on the slider knob... --&gt;
  &lt;Slider Name="HorizontalSlider" 
      MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave" 
      ValueChanged="Slider_ValueChanged" /&gt;
  &lt;Slider Name="VerticalSlider" Orientation="Vertical" 
      MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave" 
      ValueChanged="Slider_ValueChanged" /&gt;
  </code></pre>
  
  <p>Since many controls in this example are calling the same two functions "GeneralMouseEnter" and "GeneralMouseLeave", I'd like to be able to define a style or something similar to encapsulate that behavior.</p>
  
  <p>[edit - clarification]<br>
  <strong>This is supposed to become a kind of plugin later on.</strong><br>
  (Include code and XAML files to any GUI program and set a style on each interactive control element...)</p>
  
  <p>From what I found on the web, I can use <code>EventTriggers</code> like in this example:</p>
  
  <pre><code>&lt;Style.Triggers&gt;
    &lt;EventTrigger RoutedEvent="Click"&gt;
      &lt;EventTrigger.Actions&gt;
        &lt;BeginAction TargetName="SomeAction" /&gt;
      &lt;/EventTrigger.Actions&gt;
    &lt;/EventTrigger&gt;
  &lt;/Style.Triggers&gt;
  </code></pre>
  
  <p>I don't know though if and how to call functions within an action.</p>
  
  <ul>
  <li>Is it possible to get this functionality by creating a style with action + trigger to be applied to each control? How to do that?</li>
  <li>How do I assign multiple styles (for multiple interaction events) to one control?</li>
  <li>Is there maybe even a cleaner way to achieve this behavior?</li>
  <li>[edit]<br>
  <em>What if I want to, let's say, have mouse interaction on all sliders in my GUI?</em></li>
  </ul>