Version

Managing Undo/Redo (xamRichTextEditor)

Topic Overview

Purpose

This topic explains the xamRichTextEditor ™ control’s Undo and Redo operations from a developer’s perspective.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic provides an overview of the features supported by the xamRichTextEditor control.

This topic explains the document’s content logical structure you can use to edit the contents in the xamRichTextEditor programmatically.

This topic provides detailed instructions to help you get up and running as quickly as possible with the xamRichTextEditor .

In this topic

This topic contains the following sections:

Introduction

Introduction to the Undo and Redo support

The UndoManager is available programmatically via the RichTextDocument’s UndoManager property. By default, each RichTextDocument has its own UndoManager, which means you will have a separate history of all changes for each RichTextDocument in your application. Alternatively, you can configure a single UndoManager to multiple `RichTextDocument`s thereby allowing you to have a shared history tracking all the revisions across all `RichTextDocument`s.

Control Configuration Summary

Control configuration summary chart

The following table lists the Undo and Redo operation with details.

Operation Details

Performs an Undo operation on the specified xamRichTextEditor instance.

Performs a Redo operation on the specified xamRichTextEditor instance.

Undo Operation

Overview

The undo operation incrementally rolls back the last changes made on the RichTextDocument, returning the text to its original state, pops the Undo operation record off the undo history stack and adds it to the top of the Redo history stack.

Property settings

In order to: Do the following:

Perform an Undo operation using command

Instantiate a RichTextEditorCommandSource class and set the following properties:

Perform an Undo operation using code

Invoke the Undo method of the UndoManager of the respective xamRichTextEditor’s document.

Example

In XAML:

Example
<Button Content="Undo">
    <ig:Commanding.Command>
        <igPrim:RichTextEditorCommandSource
            EventName="Click" CommandType="Undo" TargetName="xamRichTextEditor1" />
    </ig:Commanding.Command>
</Button>

In C#:

this.xamRichTextEditor1.Document.UndoManager.Undo();

In Visual Basic:

Me.xamRichTextEditor1.Document.UndoManager.Undo()

Redo Operation

Overview

The Redo operation incrementally backs out the changes inserted by the Undo operation on the RichTextDocument, returning the text to its most recently edited state, pops the Undo operation record off the redo history stack and adds it to the top of the undo history stack.

Property settings

In order to: Do the following:

Perform an Undo operation using command

Instantiate a RichTextEditorCommandSource class and set the following properties:

  • EventName

  • CommandType

  • TargetName

Perform an Undo operation using code

Invoke the Redo method of the UndoManager of the respective xamRichTextEditor’s document

Example

In XAML:

Example
<Button Content="Redo">
    <ig:Commanding.Command>
        <igPrim:RichTextEditorCommandSource
            EventName="Click" CommandType="Redo" TargetName="xamRichTextEditor1" />
    </ig:Commanding.Command>
</Button>

In C#:

this.xamRichTextEditor1.Document.UndoManager.Redo();

In Visual Basic:

Me.xamRichTextEditor1.Document.UndoManager.Redo()

Related Topics

The following topic provides additional information related to this topic.

Topic Purpose

This topic explains how to turn on and off the xamRichTextEditor control’s undo logging funtionality.