Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6973137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:04:11+00:00 2026-05-27T17:04:11+00:00

I have RichTextBox in WPF which contains InlineUIContainer with some custom objects. How to

  • 0

I have RichTextBox in WPF which contains InlineUIContainer with some custom objects. How to allow Undo event for that UIContainer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:04:11+00:00Added an answer on May 27, 2026 at 5:04 pm

    First of all bind a command to your undo button.
    Write a CommandBinding similar to this:
    <CommandBinding Command="Undo" Executed="ExecuteUndo" CanExecute="CanExecuteUndo"/>

    Then set the Content of the RichTextBox to something like this

    {Binding myUndoManager.CurrentContent, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}

    myUndoManager is a DependencyProperty with type of UndoManager class. You need to implement this class and inherit it from DependencyObject and INotifyPropertyChanged. within this class, CurrentContent is a DependencyProperty which keeps the proper content to show and PropertyChanged event handles every changes to the Content of the RichTextBox. (you can add a collection to the class and with each call to this event, add a new item to the collection. the type of the items for this collection might have some properties like TextDifferences, ActionType, …)

    Then all that is left is to implement the body of CanExecuteUndo and ExecuteUndo inside your code. (e.CanExecute could be set to true inside the CanExecuteUndo, if and only if the collection is not empty. And ExecuteUndo pops out the last item from the collection and according to its ActionType does the necessary actions)

    And don’t forget to set the DataContext of the window(or RichTextBox) to {Binding RelativeSource={RelativeSource Self}} if myUndoManager object is in the same class as the window.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RichTextBox which contains links posted by the users. The problem is
I have a small WPF application that hosts a RichTextBox: <RichTextBox SpellCheck.IsEnabled=True FontFamily=Verdana AcceptsTab=True
I have a WPF RichTextBox which contain in its FlowDocument both text and images.
I have a richtextbox that its text is a concatenation of some words from
I have a WPF RichTextBox control that I want to behave like a normal
I have a richtextbox (WPF extended toolkit) that I am using in my WPF
I have the problem where i have a WPF RichTextBox, and i'm extracting its
I have a RichTextBox that I write a string to every time I click
I have a Windows Forms application that on it I have a RichTextBox, like
I have a simple vb6 editor type application which has a richtextbox as the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.