Verticall scroll richtextbox on the bottom [WPF]

a 夏天 提交于 2019-12-24 02:25:07

问题


I have a richtextbox and when is full I want automatically scroll to the bottom, It is possible? Do this with xaml?


回答1:


By using ScrollViewer.ScrollChanged routed event, and writing some code (for example, richTextBox1.ScrollToEnd()), you may be able to do what you want.




回答2:


RichTextBox has a ScrollToEnd method that could be called in the Codebehind. I don't know a way to do this in XAML only.




回答3:


Assuming your RichTextBox is named Output, attach this method to its TextChanged event:

void Output_TextChanged(object sender, TextChangedEventArgs e)
{
    Output.ScrollToEnd();
}


来源:https://stackoverflow.com/questions/4256129/verticall-scroll-richtextbox-on-the-bottom-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!