Possible ScrollToDocumentEnd() bug?

SyntaxEditor for WPF Forum

Posted 14 years ago by Matt Kerchmar
Avatar
Hello,

I am attempting to implement an Output Window in my application to mimic functionality similar to Visual Studio's Output Window. I am using a SyntaxEditor control so that I can have syntax highlighting in the output window, because code will often be dumped to the output as the application is being used. As output text is appended to the window, the editor needs to stay scrolled to the end.

Is this not the correct function for this purpose?

SyntaxEditor.ActiveView.Scroller.ScrollToDocumentEnd()

I verified with a breakpoint that this line is getting hit when text is appended to the editor control (as expected). But it doesn't scroll.

An alternative method I thought of involved determining the number of lines in the document and simply scrolling to the last line with:

SyntaxEditor.Caret.Position = new TextPosition(lastLine, 0);

or

SyntaxEditor.ActiveView.FirstVisiblePosition = new TextPosition(lastLine, 0);

But, unfortunately, I don't know how to determine the number of lines in a document (I have another forum posting that asks this question for another purpose).

Any suggestions would be greatly appreciated.

Thanks,
Matt Kerchmar

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you are using the AppendText with normal options, the caret should be auto-moving to the end of the text insert. So really you shouldn't have to do anything extra to keep it in view.

I tested ScrollToDocumentEnd here and it seemed to work fine.

If you think there is a problem, please email us a simple sample project that shows the issue. Thanks.


Actipro Software Support

Posted 14 years ago by Matt Kerchmar
Avatar
Hello,

In a fresh project, ScrollToDocumentEnd worked as intended for me as well.

I believe the issue might have been related to the fact that I was reacting to a TextChanged event (not sure if that is the correct name, but it is essentially what the event handler was set up to do). Maybe there is a default scrolling handler that reacts to the same event, and it was undoing my scrolling.

Not sure, but it doesn't matter, because using AppendText with normal options made it no longer need the event handler at all.
The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.