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

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

问题描述

例如像 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 TextBox 自动滚动到底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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