Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top