Thursday, 15 August 2013

Moving to the end of the text in a readonly TextBox

Moving to the end of the text in a readonly TextBox

I currently have a TextBox in my WPF application that is readonly:
<TextBox x:Name="TextBox_CurrentDirectory" IsReadOnly="True"></TextBox>
And I update the text in the Code Behind:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var app = Application.Current as App;
TextBox_ActiveDirectory.Text = app.ActiveDirectory;
//Show the end of the text here
}
I tried using
TextBox_ActiveDirectory.CaretIndex = TextBox_ActiveDirectory.Text.Length;
but nothing happens.
Is there a way for me to show the end of the text programmatically? If the
text in the TextBox is longer than the TextBox, it only shows the start
and gets cut off. I'd like to be able to show the end of the text.

No comments:

Post a Comment