IsUndoEnabled with DataBinding and .Net 3.5

Oct 15, 2012 at 3:19 PM


First off all, create project!

Unfortunately i've a problem with DataBound TextBoxes in .Net 3.5. I've a couple of TextBoxes and want to create a Window-Undo-Handling. If I set "IsUndoEnabled" to False for each TextBox, I get an exception called "Cannot use UndoService while it is disabled." This is a known bug for .Net 3.5.

Does anybody knows a workaround, working with the muf-framework? I use MVVM.


Thanks in advance Marcel.

Oct 17, 2012 at 2:03 AM

Hi @flitzpiepe,

Thanks for taking a look at the project.

You should be able to use the MUF framework to make the textboxes "undo-able". I'm pretty sure that it should work fine, even in .NET 3.5.

Can you post a little bit of code / xaml that shows what you're doing? It sounds like you're on the right track. You'll want to disable the built-in Undo capabilities of the textbox. And then you'll hook up MUF inside your ViewModels to capture the changes. Then you'll want to hook the appropriate keyboard shortcuts / button clicks to invoke and undo or a redo.

Is this what you have setup? If you need a working example, there are a couple examples in the source code.

- Nathan

Apr 23, 2014 at 12:19 PM
I have same issue with .NET 3.5 and default textbox.
In style undo is disabled and limit set to 0.
Then on text changed i have exception "Cannot use UndoService while it is disabled."
Apr 23, 2014 at 12:22 PM
Edited Apr 23, 2014 at 12:28 PM
Fond next fix:

Some days back, I had blogged about this issue and suggested how to set global style to counter this. However it turns out that with that you may run into 'Cannot use UndoService while it is disabled' related error. To address that, you will need to modify the style using a DataTrigger as below.
    <Style TargetType="{x:Type TextBox}">
            <DataTrigger Binding="{Binding Path=IsLoaded, RelativeSource={RelativeSource Self}}" Value="True">
                <Setter Property="UndoLimit" Value="0" />