我目前在我的WPF应用程序中有一个只读的TextBox:
<TextBox x:Name="TextBox_CurrentDirectory" IsReadOnly="True"></TextBox>
并且文本在代码后端得到更新:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var app = Application.Current as App;
TextBox_CurrentDirectory.Text = app.ActiveDirectory;
//Show the end of the text here
}
有没有一种方法可以通过编程方式显示文本的结尾?如果TextBox中的文本比TextBox更长,则仅显示开头并被截断。我想能够显示文本的结尾。
我尝试使用
TextBox_CurrentDirectory.CaretIndex = TextBox_CurrentDirectory.Text.Length;
但是什么都没有发生。
ScrollToEnd()
方法就可以了,是吗? - King KingScrollToEnd
可能是针对多行文本框的。 - keyboardP