0

I am trying to initially calculate ExtentHeight of rendered text displayed in AvalonEdit control to prevent scroll jumping after VisualLineElementGenerators are applied. VisualLineElementGenerator that I use adds extra vertical space between certain lines. My first guess was to construct all visual lines when the editor is loaded, the code is presented below.

foreach (var line in TextEditor.Document.Lines)
  TextEditor.TextArea.TextView.GetOrConstructVisualLine(line);

It seems to work, but not exactly as I would expect. The ExtentHeight value is still getting updated when user scrolls. The interesting fact is, that the ExtendHeight value calculated initially is bigger than the actual value, so it gets reduced. I also noticed that DefaultLineHeight, DefaultBaseline and several other values from TextView are different when all visual lines are constructed initially and after the lines are actually rendered. A desirable is to calculate the ExtentHeight that remains fixed regardless of scrolling. Thanks!

  • That sounds weird. Are you sure that "when the editor is loaded", it already has the correct font, TextRenderingOptions etc. set? If those are inherited from parent controls and/or applied by data binding, the values might not be available initially. – Daniel Mar 10 '16 at 20:13
  • That was the point, I figured out that the control needs to be both loaded and visible before constructing all visual lines. – tooooomasz Mar 11 '16 at 11:33

0 Answers0