Avalonedit how to get the top visible line
-
25-06-2021 - |
Frage
In Avalonedit, how do I get the line number of the very top line that is visible to the user?
I believe I'm supposed to make some use out of VisualLines but it isn't helping.
Lösung
You can use GetDocumentLineByVisualTop
:
int firstLine = textView.GetDocumentLineByVisualTop(textView.ScrollOffset.Y).LineNumber;
textView.VisualLines[0].FirstDocumentLine.LineNumber
would work as well, but you have to be careful there - the visual lines collection can be invalid if a redraw was requested but not performed yet (see VisualLinesValid
/EnsureVisualLines()
).
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow