This is a migrated thread and some comments may be shown as answers.

Hook into document history undo stack

1 Answer 142 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 18 Nov 2016, 08:06 PM
We have an application with certain behaviors that require modifying the document model directly. Doing this clears the undo stack. Is there any way that we can hook into the document undo stack so that we can support undoing our custom actions to the document?

1 Answer, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 22 Nov 2016, 09:31 AM
Hello Chris,

The undo stack will preserve actions only executed by the RadRichTextBox commands. I am afraid that it is not possible to preserve direct modification as an undo action.

Nevertheless, the commands should be able to execute all kinds of actions in order to modify the document in a state that should be suitable for your scenario. In addition, there are undo groups which are designed to combine multiple commands into a single undo group. Here is example of this functionality could be used:
this.radRichTextBox.BeginUndoGroup();
this.radRichTextBox.Insert("hello");
this.radRichTextBox.InsertParagraph();
this.radRichTextBox.Insert("world");
this.radRichTextBox.EndUndoGroup("Insert Predefined Content");

And here is a link to the RadDocumentEditor help with more examples.

If this approach is not suitable for your scenario you could provide more details on what you are trying to achieve. This way we will be able to provide you with the best solution for your specific case.


Regards,
Mihail
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
RichTextBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Share this question
or