ITextDocument ITextDocument ITextDocument Interface

Definition

Provides access to the content of a document, providing a way to load and save the document to a stream, retrieve text ranges, get the active selection, set default formatting attributes, and so on.

public interface ITextDocumentpublic interface ITextDocumentPublic Interface ITextDocument
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

CaretType CaretType CaretType

Gets or sets the caret type.

public CaretType CaretType { get; set; }public CaretType CaretType { get; set; }Public ReadWrite Property CaretType As CaretType
Value
CaretType CaretType CaretType

The caret type.

Attributes

DefaultTabStop DefaultTabStop DefaultTabStop

Gets or sets the default tab spacing.

public float DefaultTabStop { get; set; }public float DefaultTabStop { get; set; }Public ReadWrite Property DefaultTabStop As float
Value
float float float

The new default tab spacing. The default value is 36.0 points, or 0.5 inches.

Attributes

Remarks

The default tab spacing is used whenever no tab exists beyond the desired display position.

Selection Selection Selection

Gets the active text selection.

public ITextSelection Selection { get; }public ITextSelection Selection { get; }Public ReadOnly Property Selection As ITextSelection
Value
ITextSelection ITextSelection ITextSelection

The active text selection.

Attributes

UndoLimit UndoLimit UndoLimit

Gets or sets the maximum number of actions that can be stored in the undo queue.

public uint UndoLimit { get; set; }public uint UndoLimit { get; set; }Public ReadWrite Property UndoLimit As uint
Value
uint uint uint

The maximum number of undo actions.

Attributes

Methods

ApplyDisplayUpdates() ApplyDisplayUpdates() ApplyDisplayUpdates()

Decrements an internal counter that controls whether text updates are displayed immediately or batched.

public int ApplyDisplayUpdates()public int ApplyDisplayUpdates()Public Function ApplyDisplayUpdates() As int
Returns
int int int

The value of the internal counter.

Attributes

Remarks

If the internal counter goes to zero, text updates are displayed immediately instead of batched.

This method cannot decrement the internal counter below zero, and no error occurs if it is called when the counter is already zero.

To increment the internal counter, call the ITextDocument.BatchDisplayUpdates method.

Note

If undo grouping is on (see ITextDocument.BeginUndoGroup ), screen updating is suppressed regardless of the internal counter's value.

BatchDisplayUpdates() BatchDisplayUpdates() BatchDisplayUpdates()

Increments an internal counter that controls whether text updates are displayed immediately or batched.

public int BatchDisplayUpdates()public int BatchDisplayUpdates()Public Function BatchDisplayUpdates() As int
Returns
int int int

The value of the internal counter.

Attributes

Remarks

If the internal counter is nonzero, text updates are batched. This lets you perform a sequence of editing operations without the performance loss and flicker of screen updating.

To decrement the internal counter, call the ITextDocument.ApplyDisplayUpdates method.

Note

If undo grouping is on (see ITextDocument.BeginUndoGroup ), screen updating is suppressed regardless of the internal counter's value.

BeginUndoGroup() BeginUndoGroup() BeginUndoGroup()

Turns on undo grouping.

public void BeginUndoGroup()public void BeginUndoGroup()Public Function BeginUndoGroup() As void
Attributes

Remarks

An undo group collects undo anti-events for editing changes even when additional undo groups would normally be created. For example, typing anti-events are normally grouped into a single undo group that can be undone with a single Ctrl+Z key combination. A paste or change in insertion point terminates the current undo group and starts another. After you call BeginUndoGroup, such terminations do not occur; only one undo group is used until you call the EndUndoGroup method. The entire group is undone by a single Ctrl+Z key combination.

When undo grouping is on:

  • The undo manager adds undo anti-events for text changes to the current undo group.
  • A single undo command executes all of the undo anti-events in the undo group. This restores the text state to the one that was active when undo grouping was turned on.

CanCopy() CanCopy() CanCopy()

Determines whether document content can be copied to the Clipboard.

public bool CanCopy()public bool CanCopy()Public Function CanCopy() As bool
Returns
bool bool bool

True if copying to the Clipboard is allowed; otherwise false.

Attributes

Remarks

Copying is allowed unless the document is copy-protected.

CanPaste() CanPaste() CanPaste()

Determines whether the Clipboard has content that can be pasted into the document.

public bool CanPaste()public bool CanPaste()Public Function CanPaste() As bool
Returns
bool bool bool

True if the Clipboard has content that can be pasted into the document; otherwise false.

Attributes

Remarks

Pasting is allowed unless the control is read-only or the selection is protected and the client refuses permission to paste.

CanRedo() CanRedo() CanRedo()

Determines whether one or more redo operations exist.

public bool CanRedo()public bool CanRedo()Public Function CanRedo() As bool
Returns
bool bool bool

True if one or more redo operations exist; otherwise false.

Attributes

CanUndo() CanUndo() CanUndo()

Determines whether one or more undo operations exist.

public bool CanUndo()public bool CanUndo()Public Function CanUndo() As bool
Returns
bool bool bool

True if one or more undo operations exist; otherwise false.

Attributes

EndUndoGroup() EndUndoGroup() EndUndoGroup()

Turns off undo grouping.

public void EndUndoGroup()public void EndUndoGroup()Public Function EndUndoGroup() As void
Attributes

GetDefaultCharacterFormat() GetDefaultCharacterFormat() GetDefaultCharacterFormat()

Retrieves the default character formatting attributes of the document.

public ITextCharacterFormat GetDefaultCharacterFormat()public ITextCharacterFormat GetDefaultCharacterFormat()Public Function GetDefaultCharacterFormat() As ITextCharacterFormat
Returns

The default character formatting attributes.

Attributes

GetDefaultParagraphFormat() GetDefaultParagraphFormat() GetDefaultParagraphFormat()

Retrieves the default paragraph formatting attributes of the document.

public ITextParagraphFormat GetDefaultParagraphFormat()public ITextParagraphFormat GetDefaultParagraphFormat()Public Function GetDefaultParagraphFormat() As ITextParagraphFormat
Returns

The default paragraph formatting attributes.

Attributes

GetRange(Int32, Int32) GetRange(Int32, Int32) GetRange(Int32, Int32)

Retrieves a new text range for the active story of the document.

public ITextRange GetRange(Int32 startPosition, Int32 endPosition)public ITextRange GetRange(Int32 startPosition, Int32 endPosition)Public Function GetRange(startPosition As Int32, endPosition As Int32) As ITextRange
Parameters
startPosition
System.Int32 System.Int32 System.Int32

The starting position of the new text range, relative to the beginning of the story.

endPosition
System.Int32 System.Int32 System.Int32

The ending position of the new text range.

Returns

The new text range.

Attributes

GetRangeFromPoint(Point, PointOptions) GetRangeFromPoint(Point, PointOptions) GetRangeFromPoint(Point, PointOptions)

Retrieves the degenerate (empty) text range at, or nearest to, a particular point on the screen.

public ITextRange GetRangeFromPoint(Point point, PointOptions options)public ITextRange GetRangeFromPoint(Point point, PointOptions options)Public Function GetRangeFromPoint(point As Point, options As PointOptions) As ITextRange
Parameters
point
Point Point Point

The location of the point on the screen, in screen coordinates.

options
PointOptions PointOptions PointOptions

The alignment type of the specified point.

Returns

The text range object.

Attributes

GetText(TextGetOptions, String) GetText(TextGetOptions, String) GetText(TextGetOptions, String)

Gets the text in the active story (document).

public void GetText(TextGetOptions options, String value)public void GetText(TextGetOptions options, String value)Public Function GetText(options As TextGetOptions, value As String) As void
Parameters
options
TextGetOptions TextGetOptions TextGetOptions

The text retrieval options.

value
System.String System.String System.String

The text in the active story.

Attributes

LoadFromStream(TextSetOptions, IRandomAccessStream) LoadFromStream(TextSetOptions, IRandomAccessStream) LoadFromStream(TextSetOptions, IRandomAccessStream)

Loads a document from a stream.

public void LoadFromStream(TextSetOptions options, IRandomAccessStream value)public void LoadFromStream(TextSetOptions options, IRandomAccessStream value)Public Function LoadFromStream(options As TextSetOptions, value As IRandomAccessStream) As void
Parameters
options
TextSetOptions TextSetOptions TextSetOptions

The text options to use for the loading the document.

value
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The random access stream that contains the document.

Attributes

Redo() Redo() Redo()

Reverses the most recent undo operation.

public void Redo()public void Redo()Public Function Redo() As void
Attributes

SaveToStream(TextGetOptions, IRandomAccessStream) SaveToStream(TextGetOptions, IRandomAccessStream) SaveToStream(TextGetOptions, IRandomAccessStream)

Saves the document to a stream.

public void SaveToStream(TextGetOptions options, IRandomAccessStream value)public void SaveToStream(TextGetOptions options, IRandomAccessStream value)Public Function SaveToStream(options As TextGetOptions, value As IRandomAccessStream) As void
Parameters
options
TextGetOptions TextGetOptions TextGetOptions

The text options for saving the document.

value
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The random access stream for saving the document.

Attributes

SetDefaultCharacterFormat(ITextCharacterFormat) SetDefaultCharacterFormat(ITextCharacterFormat) SetDefaultCharacterFormat(ITextCharacterFormat)

Sets the default character formatting attributes of the document.

public void SetDefaultCharacterFormat(ITextCharacterFormat value)public void SetDefaultCharacterFormat(ITextCharacterFormat value)Public Function SetDefaultCharacterFormat(value As ITextCharacterFormat) As void
Parameters
value
ITextCharacterFormat ITextCharacterFormat ITextCharacterFormat

The new default character formatting attributes.

Attributes

SetDefaultParagraphFormat(ITextParagraphFormat) SetDefaultParagraphFormat(ITextParagraphFormat) SetDefaultParagraphFormat(ITextParagraphFormat)

Sets the default paragraph formatting attributes of the document.

public void SetDefaultParagraphFormat(ITextParagraphFormat value)public void SetDefaultParagraphFormat(ITextParagraphFormat value)Public Function SetDefaultParagraphFormat(value As ITextParagraphFormat) As void
Parameters
value
ITextParagraphFormat ITextParagraphFormat ITextParagraphFormat

The default paragraph formatting attributes.

Attributes

SetText(TextSetOptions, String) SetText(TextSetOptions, String) SetText(TextSetOptions, String)

Sets the text of the document.

public void SetText(TextSetOptions options, String value)public void SetText(TextSetOptions options, String value)Public Function SetText(options As TextSetOptions, value As String) As void
Parameters
options
TextSetOptions TextSetOptions TextSetOptions

Options controlling how the text is inserted into the document.

value
System.String System.String System.String

The new text.

Attributes

Remarks

If the string is NULL, the text in the document is deleted.

Undo() Undo() Undo()

Undoes the most recent undo group.

public void Undo()public void Undo()Public Function Undo() As void
Attributes