故事板不会重新开始

时间:2011-12-01 21:48:14

标签: wpf silverlight storyboard

我有一个在Silverlight应用程序上工作正常的旋转木马,它来自这个网站: Carousel app

现在我想将其转换为WPF应用程序。这个问题是当在StoryBoard.Completed事件中调用storyboard.begin()时,故事板不会再次启动

private Storyboard timer;
public override void OnApplyTemplate()
{
this.timer.Completed -= new EventHandler(timer_Completed);
this.timer.Completed += new EventHandler(timer_Completed);
this.timer.Begin();
}
void timer_Completed(object sender, EventArgs e)
{
///Code to animate the carousel
this.timer.Begin();
}

故事板在OnApplyTemplate中初始化,通过在xaml中定义的名称检索它

只发生一个已完成事件

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

你有没有剪掉一些代码?我猜它实际上并没有在timer_Completed结束时进入Begin()调用,可能在此之前发生了一些异常。