Question

Determining the number of lines in a document

Posted 4 years ago by Avatar Matt Kerchmar
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 4 years ago by Actipro Software Support - Cleveland, OH, USA
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 4 years ago by Matt Kerchmar
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
Information The latest build of this product (2014.1 build 0601) was released 29 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.