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.

有帮助吗?

解决方案

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()).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top