title: How to implement the idea inside Style?
body: <p>The idea:</p>
  
  <p>There is grid inside Window. I need to create Style for 2 scenarios.</p>
  
  <p>Scenario 1:</p>
  
  <ol>
  <li>Mouse enters grid.</li>
  <li>Mouse leaves grid</li>
  <li>Grid's background becomes Red.</li>
  </ol>
  
  <p>Scenario 2:</p>
  
  <ol>
  <li>Mouse enters grid.</li>
  <li>Mouse presses on grid.</li>
  <li>Mouse leaves grid.</li>
  <li>Grid's background becomes blue.</li>
  </ol>
  
  <p>Shortly: If mouse presses - make it blue, if not - make it red.</p>
  
  <p>I tried, but to set Binding or DynamicResource on freezable objects like Storyboard inside Style is impossible.</p>
  
  <p>XAML:</p>
  
  <pre><code>    &lt;Window.Resources&gt;
      &lt;Style x:Key="GridStyle1" TargetType="{x:Type Grid}"&gt;
          &lt;Style.Resources&gt;
              &lt;Storyboard x:Key="OnMouseLeave1"&gt;
                  &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="{x:Null}"&gt;
                      &lt;EasingColorKeyFrame KeyTime="0:0:0.2" Value="Red"/&gt;
                  &lt;/ColorAnimationUsingKeyFrames&gt;
              &lt;/Storyboard&gt;
          &lt;/Style.Resources&gt;
          &lt;Style.Triggers&gt;
              &lt;EventTrigger RoutedEvent="UIElement.MouseLeave"&gt;
                  &lt;BeginStoryboard Storyboard="{StaticResource  OnMouseLeave1}"/&gt;
              &lt;/EventTrigger&gt;
          &lt;/Style.Triggers&gt;
          &lt;Setter Property="Background" Value="Black"/&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid x:Name="grid" Style="{DynamicResource GridStyle1}" Background="White"/&gt;
  </code></pre>