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 CaretType

    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 float

    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 ITextSelection

    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 uint

    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 int

    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 int

    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 void

    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 bool

    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 bool

    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 bool

    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 bool

    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 void
  • GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()
    GetDefaultCharacterFormat()

    Retrieves the default character formatting attributes of the document.

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

    Returns

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

    Retrieves the default paragraph formatting attributes of the document.

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

    Returns

  • GetRange(System.Int32,System.Int32)
    GetRange(System.Int32,System.Int32)
    GetRange(System.Int32,System.Int32)
    GetRange(System.Int32,System.Int32)

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

    public ITextRange GetRange(System.Int32,System.Int32)public ITextRange GetRange(System.Int32,System.Int32)Public Function GetRange(System.Int32,System.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

  • GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)
    GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)
    GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)
    GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)

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

    public ITextRange GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)public ITextRange GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions)Public Function GetRangeFromPoint(Windows.Foundation.Point,Windows.UI.Text.PointOptions) As ITextRange

    Parameters

    Returns

  • GetText(Windows.UI.Text.TextGetOptions,System.String)
    GetText(Windows.UI.Text.TextGetOptions,System.String)
    GetText(Windows.UI.Text.TextGetOptions,System.String)
    GetText(Windows.UI.Text.TextGetOptions,System.String)

    Gets the text in the active story (document).

    public void GetText(Windows.UI.Text.TextGetOptions,System.String)public void GetText(Windows.UI.Text.TextGetOptions,System.String)Public Function GetText(Windows.UI.Text.TextGetOptions,System.String) As void

    Parameters

  • LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)
    LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)
    LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)
    LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)

    Loads a document from a stream.

    public void LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)public void LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream)Public Function LoadFromStream(Windows.UI.Text.TextSetOptions,Windows.Storage.Streams.IRandomAccessStream) As void

    Parameters

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

    Reverses the most recent undo operation.

    public void Redo()public void Redo()Public Function Redo() As void
  • SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)
    SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)
    SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)
    SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)

    Saves the document to a stream.

    public void SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)public void SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream)Public Function SaveToStream(Windows.UI.Text.TextGetOptions,Windows.Storage.Streams.IRandomAccessStream) As void

    Parameters

  • SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)
    SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)
    SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)
    SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)

    Sets the default character formatting attributes of the document.

    public void SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)public void SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat)Public Function SetDefaultCharacterFormat(Windows.UI.Text.ITextCharacterFormat) As void

    Parameters

  • SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)
    SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)
    SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)
    SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)

    Sets the default paragraph formatting attributes of the document.

    public void SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)public void SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat)Public Function SetDefaultParagraphFormat(Windows.UI.Text.ITextParagraphFormat) As void

    Parameters

  • SetText(Windows.UI.Text.TextSetOptions,System.String)
    SetText(Windows.UI.Text.TextSetOptions,System.String)
    SetText(Windows.UI.Text.TextSetOptions,System.String)
    SetText(Windows.UI.Text.TextSetOptions,System.String)

    Sets the text of the document.

    public void SetText(Windows.UI.Text.TextSetOptions,System.String)public void SetText(Windows.UI.Text.TextSetOptions,System.String)Public Function SetText(Windows.UI.Text.TextSetOptions,System.String) As void

    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 void

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