Mahesh Jaiswal

Mahesh Jaiswal

  • NA
  • 2
  • 10.1k

WPF Marquee TextBlock

Jul 30 2015 7:59 AM
At each tick event of dispatchertimer, textblock marquee is jumping in wpf
 
Here is the code
<Grid Grid.Column="0">
<Canvas ClipToBounds="True" Name="canMain" Grid.Column="0" Grid.Row="0">
<TextBlock FontSize="35" FontWeight="Bold" Foreground="#ffffe400" Margin="0,0,0,0" Name="tbmarquee"></TextBlock>
</Canvas>
</Grid>
 
 
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tbmarquee.ActualWidth;
doubleAnimation.To = canMain.ActualWidth;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.Parse("0:0:20"));
tbmarquee.BeginAnimation(Canvas.RightProperty, doubleAnimation);

Answers (1)