Determining the number of lines in a document

SyntaxEditor for WPF Forum

Posted 15 years ago by Matt Kerchmar
Avatar
Hello,

I am attempting to implement a "Go To Line" feature to mimic functionality in Visual Studio. In order to present the valid range of line numbers to the user in the dialog box (in the manner that Visual Studio does), it is necessary to determine the number of lines in the current document. This is possible in the Windows Forms version of Syntax Editor with the SyntaxEditor.Document.Lines.Count property. But I haven't been able to locate anything like this in the WPF version, nor have I been able to locate anything that would take its place.

Any suggestions would be spiffy.

Thanks,
Matt Kerchmar

Comments (2)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This will do it:
document.CurrentSnapshot.Lines.Count

Remember that the current snapshot is a thread-safe read-only representation of the entire document. You can get text and line info from it. When you make a text change, a new snapshot is created but you can continue to reference and use old ones too.


Actipro Software Support

Posted 15 years ago by Matt Kerchmar
Avatar
Oh wow, okay. That is very helpful (and thanks for the explanation of what a snapshot is).

I also appreciate the really fast reply.

Thanks!

-Matt Kerchmar
The latest build of this product (v24.1.3) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.