我有两个画布和一个名为tbmarquee的文本块,在窗口加载它从上到下动画,但我想停止当我在它上面的mose,当我点击它去链接,怎么办它?
void Window1_Loaded(object sender, RoutedEventArgs e)
{
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tbmarquee.ActualHeight;
doubleAnimation.To = canMain.ActualHeight;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.Parse("0:0:10"));
tbmarquee.BeginAnimation(Canvas.TopProperty, doubleAnimation);
}
答案 0 :(得分:1)
在tbmarquee
的鼠标悬停事件处理程序上,再次调用BeginAnimation()
并将第二个参数设置为null
以停止动画:
tbmarquee.BeginAnimation(Canvas.TopProperty, null);