0

我有两个画布和一个名为 tbmarquee 的文本块,在窗口加载时它会从上到下进行动画处理,但是当我越过它时我想停下来,当我点击它时会转到链接,怎么做?

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

    }
4

1 回答 1

1

在鼠标悬停的事件处理程序上tbmarquee,再次调用BeginAnimation()第二个参数null以停止动画:

tbmarquee.BeginAnimation(Canvas.TopProperty, null);

相关问题:如何在 C#/WPF 中停止动画?

于 2014-05-01T11:47:04.530 回答