I am having a lot of trouble getting an AvalonEdit
double visualTop = textEditor.TextArea.TextView.GetVisualTopByDocumentLine(line);
I ended up figuring out that, since my text was all uniform height, I could just do line height * line# to get the offset. I first tried to do this using
(Editor.TextArea.TextView.DocumentHeight / Editor.Document.LineCount)to calculate the line height but that seemed to be slightly off, probably due to some floating point issues, and was increasingly off the mark the farther you went down in the document. But, again since my document is uniform height, I realized I could use the
TextView.DefaultLineHeight property and came up with:
double vertOffset = (Editor.TextArea.TextView.DefaultLineHeight) * Line; Editor.ScrollToVerticalOffset(vertOffset);
This very consistently scrolls to exactly the right place in the document.