我有以下代码:
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()
)但只是等到调用后续代码?
答案 0 :(得分:1)
我还不熟悉,但您可以尝试将过渡到故事板。故事板有一个已完成的事件。
编辑:
这个怎么样?
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();
答案 1 :(得分:0)
使用Thread.Sleep Method,它会阻止当前线程达到指定的毫秒数。