Line Numbers in WPF Syntax Editor

15 Jul 20221 minute to read

Edit WPF enables users to display line numbers for the content in the EditControl. Line numbers can be displayed or hidden by using the ShowLineNumber property of the EditControl class. The following lines of code can be used to display or hide line numbers in EditControl.

<sfedit:EditControl Name="editControl" ShowLineNumber="False">

editControl.ShowLineNumber = false;

The following image displays hidden line numbers.

Line Number



CaretPositionChanged event occurs when the caret position of the text in the EditControl is changed.
This event receives two arguments namely sender that handles EditControl and CaretPositionEventArgs as objects.

The CaretPositionEventArgs object contains the following properties:

  • LineNumber - Gets the current line number value of the EditControl.
  • CursorIndex - Gets the current cursor index value of the EditControl.