添加行后,如何使带有滚动条的WPF文本框自动滚动到底部? [英] How to make WPF TextBox with a scrollbar automatically scroll to the bottom when lines are added?

查看:249
本文介绍了添加行后,如何使带有滚动条的WPF文本框自动滚动到底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,像Visual Studio的输出窗口一样。

For example like Visual Studio's "Output" window does.

在XAML中是否可以做到这一点?

Is there a way to do it in XAML?

推荐答案

您可以在向该TextBox添加内容或侦听TextChanged事件时触发此方法:
TextBoxBase.ScrollToEnd()

You can whenever you add content to that TextBox or when you listen to the event TextChanged fire this method: TextBoxBase.ScrollToEnd().

这篇关于添加行后,如何使带有滚动条的WPF文本框自动滚动到底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆