Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. The wpf animation is handling twice. do not why.
so, here is the code:
C#
public void FadeIn()
{
    //fade in animation for user control
	DoubleAnimation opFadeInAnim = new DoubleAnimation(1, FadeTime);
    opFadeInAnim.Completed += delegate(object s, EventArgs e)
    {
        if (OnFadedIn != null)
        OnFadedIn(this, EventArgs.Empty);
    };
    this.BeginAnimation(UserControl.OpacityProperty, opFadeInAnim);
}

i subscribe only once for OnFadedIn event, but event is firing twice
Posted

1 solution

The problem is cannot be seen from this fragment of code along.

So, first put a break point at the point of += operation and make sure this place is executed exactly once. Mayne not, by whatever reason. If it's done just once, put a break point on the beginning of your event handler. According to your report, it will execute more than once. Then, on each stop on this break point, look at the debug window "Call stack". Using these techniques, find out where what causes event invocation in all cases; then you will be able to find out what's going wrong.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900