Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF故事板自动停止_Wpf_Animation_Storyboard - Fatal编程技术网

WPF故事板自动停止

WPF故事板自动停止,wpf,animation,storyboard,Wpf,Animation,Storyboard,我有一个故事板,似乎停止随机本身,我不能为我的生活找出原因 它似乎停止和随机间隔 private void CreateStoryboard(int from) { int? targetTo; Duration dur; targetTo = 150; dur = 150; Int32Animation element = new Int32Animation(); element.Fro

我有一个故事板,似乎停止随机本身,我不能为我的生活找出原因

它似乎停止和随机间隔

private void CreateStoryboard(int from)
    {
        int? targetTo;
        Duration dur;
        targetTo = 150;
        dur = 150;

        Int32Animation element = new Int32Animation();
        element.From = from;
        element.To = targetTo;
        element.Duration = dur;
        Storyboard.SetTargetProperty(element, new PropertyPath(CurrentFrameProperty));
        _filmstripStoryboard = new Storyboard {SpeedRatio = this.FrameRate};
        _filmstripStoryboard.Children.Add(element);
        _filmstripStoryboard.Completed += new EventHandler(FilmstripStoryboard_Completed);
         _filmstripStoryboard.Begin(this, true);
    }
正如您所看到的,im影响了自定义“CurrentFrameProperty”DP,它有一个回调方法,我可以打印当前帧

出于某种原因,我不知道为什么,故事板停止了。不会触发已完成的事件,并且将停止调用回调方法

我确信我不会在任何地方调用stop()


如果有人遇到过这个问题,或者可以帮助我调试它,我将非常感激。

您的代码应该可以工作。我不确定SpeedRatio=this.FrameRate的作用是什么,但是你可以很容易地测试你的代码。我最好的猜测是,另一段代码正在影响您的DpendencyProperty,而多线程代码正在咬您。

是解构器!我的对象引用了故事板和动画,它们被破坏了,所以动画看起来就像冻结了一样


用户错误:)

你能想出一种调试的方法吗?首先,隔离这段代码,这样你就可以100%确定如果没有其他因素可以影响你的DP,它可以工作。如果是这样,一次添加一个特性,直到你可以重现问题为止。听起来很标准,是吗?;-)祝你好运有没有办法检查情节提要(或动画)是否被处理掉?我知道IDispose接口,但是如果对象被简单地设置为null,它会被调用吗?对不起,我在这里没有深度。看到没有人对这个问题和你之前的问题做出反应,我只是想让你知道,我认为问题不在你给我们看的那段代码中。我只是把控制台语句放在保存故事板的对象的析构函数中,它们很早就被调用了。我想我需要弄清楚为什么它们被设置为null/destructed