Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:56:53+00:00 2026-05-26T12:56:53+00:00

I need help with an custom Image-Button that i have used for a while.

  • 0

I need help with an custom “Image-Button” that i have used for a while. It works great, but i can’t figure out how to animate the button with these three states (normal, mouseover, pressed):

  1. Normal to MouseOver
  2. MouseOver to Pressed

Im not that skilled with XAML so I couldn’t figure it out. Anyway here’s the code i’ve been using:

<Button Height="40" HorizontalAlignment="Left" IsEnabled="True" IsHitTestVisible="True" Margin="262,219,0,0" Name="home_btn" VerticalAlignment="Top" Width="89">
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
                <Image Name="Normal" Source="normal.png" />
                <Image Name="Hover" Source="hover.png" Visibility="Hidden" />
                <Image Name="Pressed" Source="pressed.png" Visibility="Hidden" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="ButtonBase.IsPressed" Value="True">
                    <Setter Property="UIElement.Visibility" TargetName="Normal" Value="Hidden" />
                    <Setter Property="UIElement.Visibility" TargetName="Pressed" Value="Visible" />
                </Trigger>
                <Trigger Property="UIElement.IsMouseOver" Value="True">
                    <Setter Property="UIElement.Visibility" TargetName="Normal" Value="Hidden" />
                    <Setter Property="UIElement.Visibility" TargetName="Hover" Value="Visible" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
</Button>

Any answer is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:56:53+00:00Added an answer on May 26, 2026 at 12:56 pm

    An other way to accomplish animation is to use triggers like you did in combination with Storyboards

    Here is some sample code (integrated in your posted code):

     <Button Height="40" HorizontalAlignment="Left" IsEnabled="True" IsHitTestVisible="True" Margin="262,219,0,0" Name="home_btn" VerticalAlignment="Top" Width="89">
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
                <Image Name="Normal" Source="normal.png" />
                <Image Name="Hover" Source="hover.png" Opacity="0"/>
                <Image Name="Pressed" Source="pressed.png" Opacity="0" />
            </Grid>
            <ControlTemplate.Resources>
                <Storyboard x:Key="MouseDownTimeLine">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.05" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="MouseUpTimeLine">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pressed" Storyboard.TargetProperty="Opacity">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="MouseEnterTimeLine">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="MouseExitTimeLine">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Hover" Storyboard.TargetProperty="Opacity">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                 </Storyboard>
            </ControlTemplate.Resources>
            <ControlTemplate.Triggers>
                <Trigger Property="ButtonBase.IsPressed" Value="True">
                   <Trigger.EnterActions>
                       <BeginStoryboard Storyboard="{StaticResource MouseDownTimeLine}"/>
                   </Trigger.EnterActions>
                   <Trigger.ExitActions>
                       <BeginStoryboard Storyboard="{StaticResource MouseUpTimeLine}"/>
                   </Trigger.ExitActions>
                </Trigger>
                <Trigger Property="UIElement.IsMouseOver" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource MouseEnterTimeLine}"/>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard Storyboard="{StaticResource MouseExitTimeLine}"/>
                    </Trigger.ExitActions>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CKEditor custom plugin I'm trying to write, but need some help
I need to put a custom hover menu from http://www.addthis.com/help/toolbox , but Rails uses
I have a custom canvas that I can drop controls on, move, and resize.
I try to do TableViewController and TableCell have an image. While the row can
I have a component I created that works like a Viewstack but the next
I have a custom button named ‘rename’. I need the button will always disabled.
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I have a universal iOS app with a custom view that has three buttons,
I'm building a custom view inside of Interface Builder that has buttons with image
I need some help implementing a custom role provider in a asp.net mvc app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.