0

I have two canvases and a textblock with name tbmarquee, on window load it animates from top to bottom, but i want to stop when i over the mose on it, and when i click it goes to the link, how to do it ?

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

    }
AnjumSKhan
  • 9,647
  • 1
  • 26
  • 38
nizam uddin
  • 341
  • 2
  • 6
  • 15

1 Answers1

1

On mouse over event handler of tbmarquee, call BeginAnimation() again with second argument set to null to stop the animation :

tbmarquee.BeginAnimation(Canvas.TopProperty, null);

Related question : How to stop an animation in C# / WPF?

Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137
  • adding the above code i.e calling BeginAnimation() again with null argument simply stop the animation on top without MouseOver event and it wont animate.. – nizam uddin May 02 '14 at 07:21