ITextDocument ITextDocument ITextDocument Interface

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.

Syntax

Declaration

public interface ITextDocumentpublic interface ITextDocumentPublic Interface ITextDocument

Properties summary

Gets or sets the caret type.

Gets or sets the default tab spacing.

Gets the active text selection.

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

Methods summary

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

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

Turns on undo grouping.

Determines whether document content can be copied to the Clipboard.

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

Determines whether one or more redo operations exist.

Determines whether one or more undo operations exist.

Turns off undo grouping.

Retrieves the default character formatting attributes of the document.

Retrieves the default paragraph formatting attributes of the document.

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

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

Gets the text in the active story (document).

Loads a document from a stream.

Reverses the most recent undo operation.

Saves the document to a stream.

Sets the default character formatting attributes of the document.

Sets the default paragraph formatting attributes of the document.

Sets the text of the document.

Undoes the most recent undo group.

Properties

  • CaretType
    CaretType
    CaretType
    CaretType

    Gets or sets the caret type.

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

    Property Value

  • DefaultTabStop
    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 floatpublic float DefaultTabStop { get; set; }

    Property Value

    • float
      float
      float

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

    Remarks

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

  • Selection
    Selection
    Selection
    Selection

    Gets the active text selection.

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

    Property Value

  • UndoLimit
    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 uintpublic uint UndoLimit { get; set; }

    Property Value

    • uint
      uint
      uint

      The maximum number of undo actions.

Methods

  • ApplyDisplayUpdates()
    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 intpublic int ApplyDisplayUpdates()

    Returns

    • int
      int
      int

      The value of the internal counter.

    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 BatchDisplayUpdates() method.

    Note

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

  • BatchDisplayUpdates()
    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 intpublic int BatchDisplayUpdates()

    Returns

    • int
      int
      int

      The value of the internal counter.

    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 ApplyDisplayUpdates() method.

    Note

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

  • BeginUndoGroup()
    BeginUndoGroup()
    BeginUndoGroup()
    BeginUndoGroup()

    Turns on undo grouping.

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

    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()
    CanCopy()

    Determines whether document content can be copied to the Clipboard.

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

    Returns

    • bool
      bool
      bool

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

    Remarks

    Copying is allowed unless the document is copy-protected.

  • CanPaste()
    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 boolpublic bool CanPaste()

    Returns

    • bool
      bool
      bool

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

    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()
    CanRedo()

    Determines whether one or more redo operations exist.

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

    Returns

    • bool
      bool
      bool

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

  • CanUndo()
    CanUndo()
    CanUndo()
    CanUndo()

    Determines whether one or more undo operations exist.

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

    Returns

    • bool
      bool
      bool

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

  • EndUndoGroup()
    EndUndoGroup()
    EndUndoGroup()
    EndUndoGroup()

    Turns off undo grouping.

    public void EndUndoGroup()public void EndUndoGroup()Public Function EndUndoGroup() As voidpublic void EndUndoGroup()
  • GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()

    Retrieves the default character formatting attributes of the document.

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

    Returns

  • GetDefaultParagraphFormat()
    GetDefaultParagraphFormat()
    GetDefaultParagraphFormat()
    GetDefaultParagraphFormat()

    Retrieves the default paragraph formatting attributes of the document.

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

    Returns

  • GetRange(Int32, Int32)
    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 ITextRangepublic ITextRange GetRange(Int32 startPosition, Int32 endPosition)

    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

  • GetRangeFromPoint(Point, PointOptions)
    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 ITextRangepublic ITextRange GetRangeFromPoint(Point point, PointOptions options)

    Parameters

    Returns

  • GetText(TextGetOptions, String)
    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 voidpublic void GetText(TextGetOptions options, String value)

    Parameters

  • LoadFromStream(TextSetOptions, IRandomAccessStream)
    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 voidpublic void LoadFromStream(TextSetOptions options, IRandomAccessStream value)

    Parameters

  • Redo()
    Redo()
    Redo()
    Redo()

    Reverses the most recent undo operation.

    public void Redo()public void Redo()Public Function Redo() As voidpublic void Redo()
  • SaveToStream(TextGetOptions, IRandomAccessStream)
    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 voidpublic void SaveToStream(TextGetOptions options, IRandomAccessStream value)

    Parameters

  • SetDefaultCharacterFormat(ITextCharacterFormat)
    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 voidpublic void SetDefaultCharacterFormat(ITextCharacterFormat value)

    Parameters

  • SetDefaultParagraphFormat(ITextParagraphFormat)
    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 voidpublic void SetDefaultParagraphFormat(ITextParagraphFormat value)

    Parameters

  • SetText(TextSetOptions, String)
    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 voidpublic void SetText(TextSetOptions options, String value)

    Parameters

    Remarks

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

  • Undo()
    Undo()
    Undo()
    Undo()

    Undoes the most recent undo group.

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

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.GuidAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Text.dll