Search code examples
c#uwpricheditbox

Clear undo history of UWP RichEditBox


Is there any possibiltiy to clear the undo stack of a UWP RichEditBox, because I found no property or method to accomplish this?

What I've tried is to set the document text with Document.LoadFromStream instead of Document.SetText, but the problem is that I need the SetText method as a workaround for this problem. Therefore, I need a possibility to clear the undo stack afterwards, without modifying the document's text.

Another approach, which didn't work, was to set Document.UndoLimit to 0 and then restore back.


Solution

  • Microsoft said they add the method ClearUndoRedoHistory() since 17763, refer doc. But I tried, this method does not exist. Only god knows they added. enter image description here

    =====Update======

    As Roy Li - MSFT said, Use the code below. enter image description here