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 4048666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:50:45+00:00 2026-05-20T13:50:45+00:00

I just started looking in to WPF and i ran in to interesting problem.

  • 0

I just started looking in to WPF and i ran in to interesting problem. The objective is to have a simple form with one button, when user moves his mouse over the button, button should move away, so lets say the whole process looks like this:
1. Button in position A.
2. Mouse over the button it moves to position B.
3. Mouse over the button it moves to position C.
4. Mouse over the button it moves back to position A.
5. Mouse over the button it moves to position B again.

The goal is that user never able to click the button, which runs between A to B to C to A to B and its should go on until user gives up .
I am trying to achieve this by using triggers and animation; the problem is that triggers are working only one time, after button returned to position A trigger doesn’t fire second time, so button is not moving any more.
Here is a code from xaml file.

<Window x:Class="Test_1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
  <Style TargetType="Button">
        <Style.Triggers>                
             <MultiTrigger x:Name="Aaaa" >
                <MultiTrigger.Conditions>
                    <Condition Property="Margin" Value="51,58,0,0"/>
                    <Condition Property="IsMouseOver" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.EnterActions>
                    <BeginStoryboard Name="SB2" >
                        <Storyboard Duration="0:0:1">
                            <ThicknessAnimation Storyboard.TargetProperty="Margin" To="249,199,0,0" />
                        </Storyboard>
                    </BeginStoryboard>                        
                </MultiTrigger.EnterActions>
            </MultiTrigger>
            <MultiTrigger x:Name="Bbbbb">
                <MultiTrigger.Conditions>
                    <Condition Property="Margin" Value="249,199,0,0"/>
                    <Condition Property="IsMouseOver" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.EnterActions>
                    <BeginStoryboard Name="SB3">
                        <Storyboard Duration="0:0:1">
                            <ThicknessAnimation Storyboard.TargetProperty="Margin" To="301,66,0,0" />
                        </Storyboard>
                    </BeginStoryboard>
                </MultiTrigger.EnterActions>
            </MultiTrigger>
            <MultiTrigger x:Name="Ccccc">
                <MultiTrigger.Conditions>
                    <Condition Property="Margin" Value="301,66,0,0"/>
                    <Condition Property="IsMouseOver" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.EnterActions>
                    <BeginStoryboard Name="SB4">
                        <Storyboard Duration="0:0:1">
                            <ThicknessAnimation Storyboard.TargetProperty="Margin" To="51,58,0,0"/>
                        </Storyboard>
                    </BeginStoryboard>
                </MultiTrigger.EnterActions>
            </MultiTrigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
<Grid>
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="51,58,0,0" Name="button1" VerticalAlignment="Top" Width="75" />                   
</Grid>

Thank you!!

  • 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-20T13:50:46+00:00Added an answer on May 20, 2026 at 1:50 pm

    I believe you need to stop your storyboard before you can use it again. So here’s kinda a hack for your example to get it to work: (In the exit action of each storyboard, stop the previously executed storyboard):

        <Style TargetType="Button">
            <Style.Triggers>
                <MultiTrigger x:Name="Aaaa">
                    <MultiTrigger.Conditions>
                        <Condition Property="Margin" Value="51,58,0,0"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <MultiTrigger.EnterActions >
                        <BeginStoryboard Name="SB2" >
                            <Storyboard Duration="0:0:1" >
                                <ThicknessAnimation Storyboard.TargetProperty="Margin" To="249,199,0,0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </MultiTrigger.EnterActions>
                    <MultiTrigger.ExitActions>
                        <StopStoryboard BeginStoryboardName="SB4" />
                    </MultiTrigger.ExitActions>
                </MultiTrigger>
                <MultiTrigger x:Name="Bbbbb">
                    <MultiTrigger.Conditions>
                        <Condition Property="Margin" Value="249,199,0,0"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <MultiTrigger.EnterActions>
                        <BeginStoryboard Name="SB3">
                            <Storyboard Duration="0:0:1">
                                <ThicknessAnimation Storyboard.TargetProperty="Margin" To="301,66,0,0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </MultiTrigger.EnterActions>
                    <MultiTrigger.ExitActions>
                        <StopStoryboard BeginStoryboardName="SB2" />
                    </MultiTrigger.ExitActions>
                </MultiTrigger>
                <MultiTrigger x:Name="Ccccc">
                    <MultiTrigger.Conditions>
                        <Condition Property="Margin" Value="301,66,0,0"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <MultiTrigger.EnterActions>
                        <BeginStoryboard Name="SB4">
                            <Storyboard Duration="0:0:1">
                                <ThicknessAnimation Storyboard.TargetProperty="Margin" To="51,58,0,0"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </MultiTrigger.EnterActions>
                    <MultiTrigger.ExitActions>
                        <StopStoryboard BeginStoryboardName="SB3" />
                    </MultiTrigger.ExitActions>
                </MultiTrigger>
            </Style.Triggers>
        </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started looking at javascript so hopefully this will be something simple.
I have been looking at using TDD and implementing proper testing (only just started
I am new to WPF and just started learning WPF. I am looking for
I've just started looking at JQuery. I don't have any AJAX in my web
I just started looking at split view controllers and i have some questions How
I have just started learning coding and PHP so I have been looking at
How would you test this scenario? I've just started looking into NHibernate and having
Just some days ago I started looking into a unit test framework called check,
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.