gpt4 book ai didi

avalonedit - 如何使用 Avalon TextEditor 获取当前垂直滚动条位置

转载 作者:行者123 更新时间:2023-12-03 13:19:48 29 4
gpt4 key购买 nike

外部资源:http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor

我正在使用编辑器来显示日志文件,并希望它在添加新行时始终滚动到按钮,但前提是它已经位于底部。

我找到了一个 ScrollToEnd() 但这意味着它总是滚动并且我需要某种方式来获取当前滚动位置?有谁找到过或者知道它是否不存在?

最佳答案

试试这个:

TextView textView = textEditor.TextArea.TextView;
bool isAtEnd = textView.VerticalOffset + textView.ActualHeight + 1 >= textView.DocumentHeight;

代码添加 1px 以避免浮点不准确的问题。

关于avalonedit - 如何使用 Avalon TextEditor 获取当前垂直滚动条位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15747648/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com