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

似乎停止和随机间隔。

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);
    }

正如您所见,即时通讯会影响自定义“ CurrentFrameProperty ” DP,它有一个我打印出当前帧的回调方法。

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

我确信我没有在任何地方调用stop()。

如果有人遇到此问题或者可以帮我调试,我将非常感激。

有帮助吗?

解决方案 2

这是解构主义者!参考故事板和动画的我的对象被破坏了,所以动画看起来就像是冻结了。

用户错误:)

其他提示

您的代码应该有效。我不确定SpeedRatio = this.FrameRate是做什么的,但你可以轻松地测试你的代码,删除该部分。我最好的猜测是,其他一些代码正在影响你的DpendencyProperty,而那个多线程代码正在咬你。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top