Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top