Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An other way to accomplish animation is to use triggers like you did in combination with <a href="http://msdn.microsoft.com/en-us/library/ms742868.aspx" rel="nofollow">Storyboards</a></p> <p>Here is some sample code (integrated in your posted code):</p> <pre><code> &lt;Button Height="40" HorizontalAlignment="Left" IsEnabled="True" IsHitTestVisible="True" Margin="262,219,0,0" Name="home_btn" VerticalAlignment="Top" Width="89"&gt; &lt;Button.Template&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Grid&gt; &lt;Image Name="Normal" Source="normal.png" /&gt; &lt;Image Name="Hover" Source="hover.png" Opacity="0"/&gt; &lt;Image Name="Pressed" Source="pressed.png" Opacity="0" /&gt; &lt;/Grid&gt; &lt;ControlTemplate.Resources&gt; &lt;Storyboard x:Key="MouseDownTimeLine"&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00.05" Value="1"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Key="MouseUpTimeLine"&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Key="MouseEnterTimeLine"&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Key="MouseExitTimeLine"&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/ControlTemplate.Resources&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="ButtonBase.IsPressed" Value="True"&gt; &lt;Trigger.EnterActions&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseDownTimeLine}"/&gt; &lt;/Trigger.EnterActions&gt; &lt;Trigger.ExitActions&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseUpTimeLine}"/&gt; &lt;/Trigger.ExitActions&gt; &lt;/Trigger&gt; &lt;Trigger Property="UIElement.IsMouseOver" Value="True"&gt; &lt;Trigger.EnterActions&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseEnterTimeLine}"/&gt; &lt;/Trigger.EnterActions&gt; &lt;Trigger.ExitActions&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseExitTimeLine}"/&gt; &lt;/Trigger.ExitActions&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Button.Template&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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