【问题标题】:How to get the current vertical scroll bar position with Avalon TextEdtior如何使用 Avalon TextEditor 获取当前垂直滚动条位置
【发布时间】:2013-03-22 18:36:53
【问题描述】:

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

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

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

【问题讨论】:

    标签: avalonedit


    【解决方案1】:

    试试这个:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      相关资源
      最近更新 更多