This topic explains how to create your own margins.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
The xamSyntaxEditor ™ supports placing margins in any of the four locations along the edges of the text editing area. To be able to position a margin in any of the four locations (top, bottom, left or right) the MarginBase class implements the ISupportPositioning interface. You will most likely use left and right positioned margins to display information related to the text rows and top or bottom positioned margins to display information related to the text columns.
The xamSyntaxEditor is responsible for arranging all margins at the appropriate locations. The xamSyntaxEditor also ensures that all margins have presenters by invoking the CreatePresenter method and passing the associated DocumentViewBase as an argument. The DocumentViewBase
provides the presenter with the needed context to access the view and the control information (for example, access to visible lines, events for different user interactions, etc…).
The following steps demonstrate how to create a custom margin.
Create your custom margin class by extending from the MarginBase
class.
Override the Location property of MarginBase
to position your margin at the desired location.
Override the Key property of MarginBase
to give your margin a unique key so that other margins can position themselves relative to your margin.
Override the CreatePresenter
method of MarginBase
to provide the presenter for your margin. The presenter can be any class extending from FrameworkElement.
Custom margin presenters typically override the DocumentViewBase.LayoutChanged event to trigger the rendering of the custom margin’s content.
Add your margin in the CustomMargins collection of the xamSyntaxEditor .
The following topics provide additional information related to this topic.