In This Article

ITextView Interface

Provides the base requirements for a text view.

public interface ITextView

Properties

CollapsedRegionManager

Gets an ICollapsedRegionManager that provides information about collapsed regions in the view.

ICollapsedRegionManager CollapsedRegionManager { get; }

Property Value

ICollapsedRegionManager:

An ICollapsedRegionManager that provides information about collapsed regions in the view.

CurrentSnapshot

Gets the ITextSnapshot that currently is used to populate the view.

ITextSnapshot CurrentSnapshot { get; }

Property Value

ITextSnapshot:

The ITextSnapshot that currently is used to populate the view.

DefaultBackgroundColor

Gets the default background color.

Color DefaultBackgroundColor { get; }

Property Value

Color:

The default background color.

DefaultCharacterWidth

Gets the width of an average default font character in the view.

double DefaultCharacterWidth { get; }

Property Value

double:

The width of an average default font character in the view.

DefaultFontFamilyName

Gets the default font family name.

string DefaultFontFamilyName { get; }

Property Value

string:

The default font family name.

DefaultFontSize

Gets the default font size.

float DefaultFontSize { get; }

Property Value

float:

The default font size.

DefaultForegroundColor

Gets the default foreground color.

Color DefaultForegroundColor { get; }

Property Value

Color:

The default foreground color.

DefaultLineHeight

Gets the default line height.

double DefaultLineHeight { get; }

Property Value

double:

The default line height.

DefaultSpaceWidth

Gets the width of a default font space character in the view.

double DefaultSpaceWidth { get; }

Property Value

double:

The width of a default font space character in the view.

HighlightingStyleRegistry

Gets the IHighlightingStyleRegistry used by this view.

IHighlightingStyleRegistry HighlightingStyleRegistry { get; }

Property Value

IHighlightingStyleRegistry:

The IHighlightingStyleRegistry used by this view.

IsDefaultBackgroundColorLight

Gets whether the background color of the editor is light.

bool IsDefaultBackgroundColorLight { get; }

Property Value

bool:

true if the background color of the editor is light; otherwise, false.

IsWhitespaceVisible

Gets whether whitespace (spaces and tabs) is visible.

bool IsWhitespaceVisible { get; }

Property Value

bool:

true if whitespace (spaces and tabs) is visible; otherwise, false.

Properties

Gets the dictionary containing custom properties for this object.

PropertyDictionary Properties { get; }

Property Value

PropertyDictionary:

The dictionary containing custom properties for this object.

ScrollState

Gets the view's current scroll state.

TextViewScrollState ScrollState { get; }

Property Value

TextViewScrollState:

The view's current scroll state.

SyntaxEditor

Gets the SyntaxEditor that contains the view.

SyntaxEditor SyntaxEditor { get; }

Property Value

SyntaxEditor:

The SyntaxEditor that contains the view.

TextAreaPadding

Gets the padding thickness around the text area content.

Thickness TextAreaPadding { get; }

Property Value

Thickness:

The padding thickness around the text area content.

TextAreaSize

Gets the size of the text area in text area coordinates.

Size TextAreaSize { get; }

Property Value

Size:

The size of the text area in text area coordinates.

TextAreaViewportBounds

Gets a System.Windows.Rect indicating the bounds of visible portion of the text area, relative to view coordinates.

Rect TextAreaViewportBounds { get; }

Property Value

Rect:

A System.Windows.Rect indicating the bounds of visible portion of the text area, relative to view coordinates.

UniqueId

Gets the Guid that uniquely identifies the view.

Guid UniqueId { get; }

Property Value

Guid:

The Guid that uniquely identifies the view.

VisibleViewLines

Gets the collection of ITextViewLine objects that are currently visible within the view.

ITextViewLineCollection VisibleViewLines { get; }

Property Value

ITextViewLineCollection:

The collection of ITextViewLine objects that are currently visible within the view.

Remarks

The ITextViewLine items in this collection are sorted in their display order, top to bottom.

VisualElement

Gets the FrameworkElement that represents the view.

FrameworkElement VisualElement { get; }

Property Value

FrameworkElement:

The FrameworkElement that represents the view.

ZoomLevel

Gets a percentage value indicating the zoom level.

double ZoomLevel { get; }

Property Value

double:

A percentage value indicating the zoom level. The default value is 1.0, meaning 100%.

Methods

CreateTagAggregator<T>()

Creates a new ITagAggregator<T> that collects the tag results from all ITagger<T> instances associated with this view.

ITagAggregator<T> CreateTagAggregator<T>() where T : ITag
Type Parameters:
T -

The type of ITag associated with this aggregator.

Returns

ITagAggregator<T>:

The ITagAggregator<T> that was created.

GetAdornmentLayer(AdornmentLayerDefinition)

Returns an IAdornmentLayer for the view with the specified definition.

IAdornmentLayer GetAdornmentLayer(AdornmentLayerDefinition layerDefinition)
Parameter Type Description
layerDefinition AdornmentLayerDefinition

The layer definition.

Returns

IAdornmentLayer:

An IAdornmentLayer for the view with the specified string-based key.

Remarks

If no IAdornmentLayer already exists with the specified name, one is created.

GetViewLine(TextPosition)

Returns an ITextViewLine that contains the specified TextPosition.

ITextViewLine GetViewLine(TextPosition position)
Parameter Type Description
position TextPosition

The TextPosition for which to retrieve an ITextViewLine.

Returns

ITextViewLine:

An ITextViewLine that contains the specified TextPosition.

GetViewLine(ITextViewLine, int)

Returns the ITextViewLine that is relative to the specified ITextViewLine.

ITextViewLine GetViewLine(ITextViewLine viewLine, int lineDelta)
Parameter Type Description
viewLine ITextViewLine

The source ITextViewLine.

lineDelta int

The number of lines to traverse (can be negative).

Returns

ITextViewLine:

The ITextViewLine that is relative to the specified ITextViewLine.

GetViewLine(ITextViewLine, int, bool)

Returns the ITextViewLine that is relative to the specified ITextViewLine.

ITextViewLine GetViewLine(ITextViewLine viewLine, int lineDelta, bool forceVirtualSpace)
Parameter Type Description
viewLine ITextViewLine

The source ITextViewLine.

lineDelta int

The number of lines to traverse (can be negative).

forceVirtualSpace bool

Whether to force virtual line space to be used as needed (for block selections). The default value is false.

Returns

ITextViewLine:

The ITextViewLine that is relative to the specified ITextViewLine.

GetViewLine(int)

Returns an ITextViewLine that contains the specified offset.

ITextViewLine GetViewLine(int offset)
Parameter Type Description
offset int

The offset for which to retrieve an ITextViewLine.

Returns

ITextViewLine:

An ITextViewLine that contains the specified offset.

GetViewLine(int, bool)

Returns an ITextViewLine that contains the specified offset.

ITextViewLine GetViewLine(int offset, bool hasFarAffinity)
Parameter Type Description
offset int

The offset for which to retrieve an ITextViewLine.

hasFarAffinity bool

Whether the offset has affinity for the far side, which is used when the offset is where a view line is wrapped to a second view line.

Returns

ITextViewLine:

An ITextViewLine that contains the specified offset.

InvalidateRender()

Invalidates and repaints the view's canvas.

void InvalidateRender()

OffsetToPosition(int)

Returns the TextPosition that represents the specified offset within the view lines.

TextPosition OffsetToPosition(int offset)
Parameter Type Description
offset int

The offset of a character within the document.

Returns

TextPosition:

The TextPosition that represents the specified offset within the view lines.

PerformLayout()

Ensures that the text area is updated with arranged view lines based on the current viewport size and scroll state.

void PerformLayout()

PositionToOffset(TextPosition)

Returns the offset for the specified TextPosition within the view lines.

int PositionToOffset(TextPosition position)
Parameter Type Description
position TextPosition

The TextPosition of a character within the view lines.

Returns

int:

The offset for the specified TextPosition within the view lines.

TransformFromTextArea(Point)

Transforms the specified System.Windows.Point in text area-relative coordinates to view-relative coordinates.

Point TransformFromTextArea(Point location)
Parameter Type Description
location Point

The System.Windows.Point to transform.

Returns

Point:

The transformed System.Windows.Point.

TransformFromTextArea(Rect)

Transforms the specified System.Windows.Rect in text area-relative coordinates to view-relative coordinates.

Rect TransformFromTextArea(Rect bounds)
Parameter Type Description
bounds Rect

The System.Windows.Rect to transform.

Returns

Rect:

The transformed System.Windows.Rect.

TransformToTextArea(Point)

Transforms the specified System.Windows.Point in view-relative coordinates to text area-relative coordinates.

Point TransformToTextArea(Point location)
Parameter Type Description
location Point

The System.Windows.Point to transform.

Returns

Point:

The transformed System.Windows.Point.

TransformToTextArea(Rect)

Transforms the specified System.Windows.Rect in view-relative coordinates to text area-relative coordinates.

Rect TransformToTextArea(Rect bounds)
Parameter Type Description
bounds Rect

The System.Windows.Rect to transform.

Returns

Rect:

The transformed System.Windows.Rect.

Events

Closed

Occurs when the view is closed.

event RoutedEventHandler Closed

Event Type

RoutedEventHandler

MarginsDestroyed

Occurs when the view's margins need to be destroyed.

event RoutedEventHandler MarginsDestroyed

Event Type

RoutedEventHandler

TextAreaLayout

Occurs when the layout of the lines in the text area has been updated.

event EventHandler<TextViewTextAreaLayoutEventArgs> TextAreaLayout

Event Type

EventHandler<TextViewTextAreaLayoutEventArgs>