In This Article

TextView Class

Represents a base class that can be used to implement an ITextView.

public abstract class TextView : ContentControl, ITextView
Inheritance:
object Visual UIElement FrameworkElement Control ContentControl object
Derived:
EditorView
Implements:
ITextView

Constructors

TextView(SyntaxEditor, ITextSnapshot)

Initializes an instance of the class.

protected TextView(SyntaxEditor syntaxEditor, ITextSnapshot initialSnapshot)
Parameter Type Description
syntaxEditor SyntaxEditor

The SyntaxEditor that owns the object.

initialSnapshot ITextSnapshot

The initial ITextSnapshot.

Properties

ArePartiallyVisibleViewLinesAllowed

Indicates whether partially-visible view lines are allowed, other than the first visible view line.

protected virtual bool ArePartiallyVisibleViewLinesAllowed { get; }

Property Value

bool:

true if partially-visible view lines are allowed; otherwise, false.

ClassificationTagAggregator

The IClassificationTag aggregator for the view.

protected abstract ITagAggregator<IClassificationTag>? ClassificationTagAggregator { get; }

Property Value

ITagAggregator<IClassificationTag>

CollapsedRegionManager

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

public abstract ICollapsedRegionManager? CollapsedRegionManager { get; }

Property Value

ICollapsedRegionManager

CurrentSnapshot

The ITextSnapshot that currently is used to populate the view.

public ITextSnapshot CurrentSnapshot { get; }

Property Value

ITextSnapshot

DefaultBackgroundColor

The default background color.

public Color DefaultBackgroundColor { get; }

Property Value

Color

DefaultCharacterWidth

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

public double DefaultCharacterWidth { get; }

Property Value

double

DefaultFontFamilyName

The default font family name.

public string DefaultFontFamilyName { get; }

Property Value

string

DefaultFontSize

The default font size.

public float DefaultFontSize { get; }

Property Value

float

DefaultFontStyle

The default font style.

public FontStyle DefaultFontStyle { get; }

Property Value

FontStyle

DefaultFontWeight

The default font weight.

public FontWeight DefaultFontWeight { get; }

Property Value

FontWeight

DefaultForegroundColor

The default foreground color.

public Color DefaultForegroundColor { get; }

Property Value

Color

DefaultLineHeight

The default line height.

public double DefaultLineHeight { get; }

Property Value

double

DefaultSpaceWidth

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

public double DefaultSpaceWidth { get; }

Property Value

double

HighlightingStyleRegistry

The IHighlightingStyleRegistry used by this view.

public abstract IHighlightingStyleRegistry HighlightingStyleRegistry { get; }

Property Value

IHighlightingStyleRegistry

IntraLineSpacerTagAggregator

The IIntraLineSpacerTag aggregator for the view.

protected abstract ITagAggregator<IIntraLineSpacerTag>? IntraLineSpacerTagAggregator { get; }

Property Value

ITagAggregator<IIntraLineSpacerTag>

IntraTextSpacerTagAggregator

The IIntraTextSpacerTag aggregator for the view.

protected abstract ITagAggregator<IIntraTextSpacerTag>? IntraTextSpacerTagAggregator { get; }

Property Value

ITagAggregator<IIntraTextSpacerTag>

IsDefaultBackgroundColorLight

Indicates whether the default background color of the editor is light.

public bool IsDefaultBackgroundColorLight { get; }

Property Value

bool:

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

IsWhitespaceVisible

Indicates whether whitespace (spaces and tabs) is visible.

public abstract bool IsWhitespaceVisible { get; }

Property Value

bool:

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

Properties

The dictionary containing custom properties for this object.

public PropertyDictionary Properties { get; }

Property Value

PropertyDictionary

RenderableTextRange

The text range that can be rendered.

protected virtual TextRange? RenderableTextRange { get; }

Property Value

TextRange?

Remarks

A value of null means no text range limitation.

ScrollState

The view's current scroll state.

public TextViewScrollState ScrollState { get; }

Property Value

TextViewScrollState

ScrollableContentHostBounds

A System.Windows.Rect indicating the bounds of scrollable content host, relative to view coordinates.

protected abstract Rect ScrollableContentHostBounds { get; }

Property Value

Rect

SquiggleTagAggregator

The ISquiggleTag aggregator for the view.

protected virtual ITagAggregator<ISquiggleTag>? SquiggleTagAggregator { get; }

Property Value

ITagAggregator<ISquiggleTag>

SyntaxEditor

The SyntaxEditor that contains the view.

public SyntaxEditor SyntaxEditor { get; }

Property Value

SyntaxEditor

TextAreaPadding

The padding thickness around the text area content.

public virtual Thickness TextAreaPadding { get; }

Property Value

Thickness

TextAreaSize

The size of the text area in text area coordinates.

public abstract Size TextAreaSize { get; }

Property Value

Size

TextAreaViewportBounds

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

public abstract Rect TextAreaViewportBounds { get; }

Property Value

Rect

UniqueId

The Guid that uniquely identifies the view.

public Guid UniqueId { get; }

Property Value

Guid

UnusedRegionTagAggregator

The IUnusedRegionTag aggregator for the view.

protected abstract ITagAggregator<IUnusedRegionTag>? UnusedRegionTagAggregator { get; }

Property Value

ITagAggregator<IUnusedRegionTag>

UseSyntaxEditorDisplayItemProperties

Indicates whether to use SyntaxEditor display item properties.

protected abstract bool UseSyntaxEditorDisplayItemProperties { get; }

Property Value

bool:

true if SyntaxEditor display item properties should be used; otherwise, false.

VisibleViewLines

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

public ITextViewLineCollection VisibleViewLines { get; }

Property Value

ITextViewLineCollection

Remarks

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

VisualElement

The FrameworkElement that represents the view.

public FrameworkElement VisualElement { get; }

Property Value

FrameworkElement

WordWrapMode

A WordWrapMode value indicating the type of word wrapping that is performed.

protected abstract WordWrapMode WordWrapMode { get; }

Property Value

WordWrapMode

WrappedLineIndentAmount

The number of characters to indent any wrapped lines beyond the original indent level of the primary line.

protected virtual int WrappedLineIndentAmount { get; }

Property Value

int:

The default value is 2.

Remarks

A value of 2 will indent wrapped lines to the original indent level of the primary line, plus 2 additional character widths. A value of 0 will indent wrapped lines to the original indent level of the primary line. A value of -1 will not indent wrapped lines at all, and will simply align them to the left edge of the view. The indent amount may be limited or altogether disabled if there is not enough available width in the view to support proper indentation.

ZoomLevel

A percentage value indicating the zoom level.

public double ZoomLevel { get; }

Property Value

double:

The default value is 1.0, meaning 100%.

Methods

Close()

Closes the view.

protected abstract void Close()

CreateTagAggregator<T>()

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

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

The type of ITag associated with this aggregator.

Returns

ITagAggregator<T>

GetAdornmentLayer(AdornmentLayerDefinition)

Returns an IAdornmentLayer for the view with the specified definition.

public abstract IAdornmentLayer GetAdornmentLayer(AdornmentLayerDefinition layerDefinition)
Parameter Type Description
layerDefinition AdornmentLayerDefinition

The layer definition.

Returns

IAdornmentLayer

Remarks

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

GetViewLine(TextPosition)

Returns an ITextViewLine that contains the specified TextPosition.

public ITextViewLine GetViewLine(TextPosition position)
Parameter Type Description
position TextPosition

The TextPosition for which to retrieve an ITextViewLine.

Returns

ITextViewLine

GetViewLine(ITextViewLine, int, bool)

Returns the ITextViewLine that is relative to the specified ITextViewLine.

public ITextViewLine GetViewLine(ITextViewLine viewLine, int lineDelta, bool forceVirtualSpace = false)
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

GetViewLine(int, bool)

Returns an ITextViewLine that contains the specified offset.

public ITextViewLine GetViewLine(int offset, bool hasFarAffinity = false)
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. The default value is false.

Returns

ITextViewLine

InvalidateRender()

Invalidates and repaints the view's canvas.

public void InvalidateRender()

OffsetToPosition(int)

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

public TextPosition OffsetToPosition(int offset)
Parameter Type Description
offset int

The offset of a character within the document.

Returns

TextPosition

OnClosed(RoutedEventArgs)

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

protected virtual void OnClosed(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

OnMarginsDestroyed(RoutedEventArgs)

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

protected virtual void OnMarginsDestroyed(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

OnRendered()

Occurs when rendering of the view is complete.

protected virtual void OnRendered()

OnScrollBarUpdateRequested(RoutedEventArgs)

Occurs when a scrollbar update is requested.

protected virtual void OnScrollBarUpdateRequested(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data.

OnScrollStatePropertyChanged(TextViewScrollState, TextViewScrollState)

Occurs when the ScrollState property is changed.

protected virtual void OnScrollStatePropertyChanged(TextViewScrollState oldValue, TextViewScrollState newValue)
Parameter Type Description
oldValue TextViewScrollState

The old value.

newValue TextViewScrollState

The new value.

OnTextAreaLayout(TextViewTextAreaLayoutEventArgs)

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

protected virtual void OnTextAreaLayout(TextViewTextAreaLayoutEventArgs e)
Parameter Type Description
e TextViewTextAreaLayoutEventArgs

The event data.

OnZoomLevelPropertyChanged(double, double)

Occurs when the ZoomLevel property is changed.

protected virtual void OnZoomLevelPropertyChanged(double oldValue, double newValue)
Parameter Type Description
oldValue double

The old value.

newValue double

The new value.

PerformLayout()

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

public void PerformLayout()

PositionToOffset(TextPosition)

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

public int PositionToOffset(TextPosition position)
Parameter Type Description
position TextPosition

The TextPosition of a character within the view lines.

Returns

int

TransformFromTextArea(Point)

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

public abstract 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.

public abstract 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.

public abstract 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.

public abstract 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.

public event RoutedEventHandler? Closed

Event Type

RoutedEventHandler

MarginsDestroyed

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

public event RoutedEventHandler? MarginsDestroyed

Event Type

RoutedEventHandler

ScrollBarUpdateRequested

Occurs when a scrollbar update is requested.

public event RoutedEventHandler? ScrollBarUpdateRequested

Event Type

RoutedEventHandler

TextAreaLayout

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

public event EventHandler<TextViewTextAreaLayoutEventArgs>? TextAreaLayout

Event Type

EventHandler<TextViewTextAreaLayoutEventArgs>

Fields

ClosedEvent

Defines the Closed event.

public static readonly RoutedEvent ClosedEvent

MarginsDestroyedEvent

Defines the MarginsDestroyed event.

public static readonly RoutedEvent MarginsDestroyedEvent

ScrollBarUpdateRequestedEvent

Defines the ScrollBarUpdateRequested event.

public static readonly RoutedEvent ScrollBarUpdateRequestedEvent

ScrollStateProperty

Defines the ScrollState property.

public static readonly DependencyProperty ScrollStateProperty

TextAreaLayoutEvent

Defines the TextAreaLayout event.

public static readonly RoutedEvent TextAreaLayoutEvent

ZoomLevelProperty

Defines the ZoomLevel property.

public static readonly DependencyProperty ZoomLevelProperty

Extension Methods