Syntax Editor Members in WPF Syntax Editor

27 Feb 20235 minutes to read

EditControl class contains variety of properties, methods and events to enable the developers utilize this control easily. It is enhanced with maximum possible level of customization and facilities that are provided for the developers to use these controls effectively. This topic discusses about the properties, methods and events available in the EditControl class.

Properties

The following table illustrates the properties in EditControl and its usages.

Name of the property

Type

Description

AcceptsTab

Boolean

Gets or sets a boolean property to allow or restrict the usage of TAB key in EditControl.

AssemblyReferences

IEnumerable(Uri)

Gets or sets a collection of type Uri, this property enables you to specify the path of assemblies from EditControl and it should fetch Intellisense items automatically.

CurrentLanguage

LanguageBase

Gets a LanguageBase instance based on the DocumentLanguage property.

CursorIndex

Int

Gets current index of text where the cursor is located in EditControl pane.

CustomLanguage

LanguageBase

Gets or sets an instance of LanguageBase type indicating the custom language.

DocumentLanguage

Languages

Gets or sets Language for the text in EditControl. Syntax highlighting and outlining of text in EditControl are performed based on the language set using this property.

DocumentSource

String

Gets or sets Source for EditControl. The filename specified will be loaded in the EditControl.

EnableIntellisense

Boolean

Gets or sets a value indicating whether Intellisense is enabled in this instance of EditControl.

EnableOutlining

Boolean

Gets or sets a value indicating whether Outlining of text in EditControl should be applied.

FindOptions

FindOptions

Gets or sets an instance of FindOptions indicating the options selected in the FindReplace Window. Click here for more details about the FindOptions.

FindResultsTabHeight

Double

Gets or sets a value indicating desired height of the find results tab.

FindResultsTabVisibility

TabVisibility

Gets or sets a value indicating the Visibility mode of the find results tab. TabVisibility is enum type containing values such as Auto, Visible and Collapsed.

HorizontalScrollBarVisibility

ScrollBarVisibility

Gets or sets a value indicating Visibility of Horizontal ScrollBar. By default, it is set to Auto, wherein the ScrollBar will be visible when required.

IntellisenseBoxStyle

Style

Gets or sets a Style to be applied to IntelliSense listbox.

IntellisenseCustomItemsSource

IEnumerable

Gets or sets a collection of business object inherited from IntellisenseItem to be displayed in the IntellisenseBox.

IntellisenseItemTemplate

DataTemplate

Gets or sets a DataTemplate to be applied to an IntellisenseBox.

IntellisenseMode

IntellisenseMode

Gets or sets a value indicating the Intellisense mode. It supports two modes viz, Auto and Custom.

In Auto mode, intellisense items are auto generated based on the language lexems, assembly references included.
In Custom mode, users have to set the IntellisenseCustomItemsSource property to specify the items to be displayed in the intellisense.

IntellisensePopupHeight

Double

Gets or sets a value indicating desired height of the IntellisensePopup.

IntellisensePopupWidth

Double

Gets or sets a value indicating desired width of IntellisensePopup.

IsFindResultsTabClosed

Boolean

Gets or sets a value indicating whether the Find Results Tab is closed or not. This property has a value `true` if the Find results tab in the EditControl is closed; otherwise, `false`.

IsReadOnly

Boolean

Gets or sets a value indicating whether Read only mode is enabled or not.

IsRedoEnabled

Boolean

Gets or sets a value indicating whether this instance supports Redo operation or not.

IsUndoEnabled

Boolean

Gets or sets a value indicating whether this instance supports Undo operation or not.

LineHeight

Double

Gets and sets the height of each line in EditControl.

LineNumber

Int

Gets the line number where the cursor is currently located.

Lines

LinesCollection

Gets the Collection of Lines in EditControl.

SearchResults

SearchResults

Gets or sets a value indicating the Search results.

SelectedText

String

Gets a value indicating the Selected text of EditControl.

ShowDefaultContextMenu

Boolean

Gets or sets a value indicating whether built-in context menu should be displayed.

ShowFindAndReplace

Boolean

Gets or sets a value indicating whether Find and Replace functionality to enabled or not.

ShowLineNumber

Boolean

Gets or sets a value indicating whether Line Number to be displayed or not. Set this to `true` to display the Line number. Default value is `true`.

TabSpaces

Int

Gets or sets a value indicating the number of Spaces to include when the tab key is pressed.

Text

String

Gets or sets a value indicating text in EditControl.

VerticalScrollBarVisibility

ScrollBarVisibility

Gets or sets a value indicating Visibility of Vertical ScrollBar. By default, it is set to Auto, wherein the ScrollBar will be visible when required.

Methods

The following table lists the methods available in EditControl class and its purpose.

Methods

Type

Description

ExpandLine(int index)

Void

a line, index in the argument refers the index of the line to be expanded (0 based value).

ExpandLineUpTopLevel(int index)

Void

Expands a line and its parent line upto the top most level. Index in the argument refers to the index of the line to be expanded (0 based value).

GetTextRange(int start, int end)

String

Returns the text between Start and End lines. Start and End denotes the index of the Start and End lines

(0 based values).

LoadFile()

Boolean

LoadFile method is used to open a file in the EditControl. It shows up a OpenFileDialog in order to select the file to be opened using EditControl and returns a boolean value stating whether file opened is successful.

LoadFile(string filename)

Boolean

This method does not display OpenFileDialog and loads the file specified as the parameter of the method. It returns a boolean value stating the file open is successful.

SaveFile()

Boolean

Save method is used to save the text in the EditControl under a file name with different supported file types.

Events

The following table lists the events available in EditControl class and its purpose.

Event

Type

Description

DocumentSourceChanged

PropertyChangedCallback

A property changed event gets raised when the DocumentSource property value is changed.

IntellisenseBoxOpening

IntellisenseBoxEventHandler

Gets raised before the Intellisense popup is displayed. This event can be used to cancel the Intellisense popup display or change ItemsSource of the Intellisense ListBox and so on.

IntellisenseBoxClosed

EventHandler

This event will be raised after the Intellisense popup is closed. This event can be used to perform any operation related to Intellisense after the popup is closed.

IntellisenseDrillDown

IntellisenseBoxEventHandler

Drill down in Intellisense occurs when the user types drill down char specified in the CurrentLanguage instance. When the drill down occurs, the Intellisense looks for any sub items are available for the selected Intellisense item and displays the popup if any. This event gets raised before the Intellisense popup is displayed after a drill down char is typed by the user. This event can be used to perform any operations related to Intellisense during drill down.

SelectedTextChanged

PropertyChangedCallback

A PropertyChangedCallback gets raised when the text in the EditControl is selected.

TextChanged

PropertyChangedCallback

A PropertyChangedCallback get raised when the text in the EditControl gets changed.

CaretPositionChanged

EventHandler

This event will be raised when the caret position of the text in the EditControl is changed. The CaretPositionChanged event receives the `sender` and CaretPositionEventArgs as argument which has the following properties.
  • Line Number : Gets the current line number value of the EditControl.
  • Cursor Index : Gets the current cursor index value of the EditControl.