1

我有以下代码:

MediaPlayer.MoveNext();

 SlideTransition slideTransition = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeOut };
 ITransition transition = slideTransition.GetTransition(textBlockSong);
 transition.Completed += delegate { transition.Stop(); };
 transition.Begin();

 //would like a pause here.       

 SlideTransition slideTransition2 = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeIn };
 ITransition transition2 = slideTransition2.GetTransition(textBlockSong);
 transition2.Completed += delegate { transition2.Stop(); };
 transition2.Begin();

然而,当第二部分立即开始时,第一个过渡没有机会运行。那么如何在两个转换之间添加暂停/延迟,这不会完全停止应用程序(如Thread.Sleep()),而只是等到调用正在进行的代码?

4

2 回答 2

1

我还不是很熟悉,但是您可以尝试将过渡放入情节提要中。Storyboard 有一个 Completed 事件。

编辑:

那这个呢?

SlideTransition slideTransition = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeOut };
ITransition transition = slideTransition.GetTransition(textBlockSong);
transition.Completed += delegate 
{ 
    transition.Stop(); 

    SlideTransition slideTransition2 = new SlideTransition { Mode = SlideTransitionMode.SlideRightFadeIn };
    ITransition transition2 = slideTransition2.GetTransition(textBlockSong);
    transition2.Completed += delegate { transition2.Stop(); };
    transition2.Begin();

};
transition.Begin();     
于 2013-08-10T23:05:31.473 回答
0

使用Thread.Sleep 方法,它将当前线程阻塞指定的毫秒数。

于 2013-08-13T16:05:56.183 回答