Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Textbox not allowing Undo when hosted in an ElementHost within a VSTO/Outlook add-in

I have an Outlook addin (VSTO), on an Outlook form region I have a WPF user control within an ElementHost. I have an issue that a TextBox within my user control does not have the undo capability... in some configurations. Specifically in Windows 7 / Outlook 2007 undo (ie Ctrl-Z) does not work, even though Cut/Copy etc all do work. Interestingly Windows 8 / Outlook 2010 undo does work.

The TextBox XAML is:

<TextBox 
    Name="txtnote" 
    VerticalScrollBarVisibility="Auto" 
    SpellCheck.IsEnabled="True"  
    Text="Topic notes..." 
    TextWrapping="Wrap" 
    AcceptsReturn="True" />

Note: I have tried setting the following attributes to make it work but to no avail: IsUndoEnabled="True" UndoLimit="-1"

Can anyone suggest why this is happening and what I can do to make it work as expected?

UPDATE 7 Jan 2014. I have added the following KeyBindings to the text box:

<TextBox.InputBindings>
    <KeyBinding Command="ApplicationCommands.Undo" Key="Z" Modifiers="Control" />
    <KeyBinding Command="ApplicationCommands.Redo" Key="Y" Modifiers="Control" />
    <KeyBinding Command="ApplicationCommands.Undo" Key="G" Modifiers="Alt" />
</TextBox.InputBindings>

And the result is - Cntl-Z/Cntrl-Y still does not work, however Alt-G does work!

like image 846
Marcin Avatar asked Dec 18 '13 11:12

Marcin


1 Answers

Plugins are not allowed to handle core Excel shortcuts. Probably due to that, shortcuts are not working.

like image 148
Sanket Tarun Shah Avatar answered Oct 03 '22 15:10

Sanket Tarun Shah