Wpf动画处理两次 [英] Wpf animation handling twice

查看:126
本文介绍了Wpf动画处理两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。 wpf动画处理两次。不要原因。
所以,这里是代码:

Hi. The wpf animation is handling twice. do not why.
so, here is the code:

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仅为 OnFadedIn 事件订阅一次,但事件发生两次


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

推荐答案

从这段代码中看不到问题。



所以,先把断点放在+ =操作点并确保此位置只执行一次。不管是什么原因,梅恩都没有。如果只完成一次,请在事件处理程序的开头添加一个断点。根据你的报告,它将执行不止一次。然后,在此断点的每个停止点上,查看调试窗口调用堆栈。使用这些技术,找出在所有情况下导致事件调用的原因;然后你就能发现出了什么问题。



-SA
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


这篇关于Wpf动画处理两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆