Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Looks like last trigger wins (try changing the order of your triggers, IsPressed first and IsMouseOver second and you'll see).</p> <p>You really should use the VisualStateManager for this kind of stuff.</p> <p>See the default's button template at the msdn for how to use the VSM.</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc278069(v=vs.95).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc278069(v=vs.95).aspx</a></p> <p>Edit for Sheridan : it works like a charm :</p> <pre><code>&lt;Window.Resources&gt; &lt;Color x:Key="OverColor"&gt;Blue&lt;/Color&gt; &lt;Color x:Key="PressedColor"&gt;Green&lt;/Color&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;Button Content="Hi sheridan!" HorizontalAlignment="Center" VerticalAlignment="Center"&gt; &lt;Button.Style&gt; &lt;Style TargetType="{x:Type Button}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Border Background="LightBlue"&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0:0:0.2"/&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Normal"/&gt; &lt;VisualState x:Name="Pressed"&gt; &lt;Storyboard&gt; &lt;ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource PressedColor}"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource OverColor}"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;ContentPresenter Content="{TemplateBinding Content}"/&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Button.Style&gt; &lt;/Button&gt; &lt;/Grid&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload