Mahesh Jaiswal

Mahesh Jaiswal

  • NA
  • 2
  • 10.6k

WPF- TextBox Control

Jul 28 2015 6:04 AM
How can we calculate the width from the text of textbox control in WPF?
 
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.LeftProperty, doubleAnimation);
 
 
<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>
 
tbmarquee.actualwidth giving 0 value 
 
please give me solution to find out the width of tbmarquee according to text 

Answers (1)