UndoManager problem when deleting links

Hi,

I’ve got a problem using the undo manager when the user removes a link (either usinig the delete key or an action clicking a button which Triggers CommandHandler.Delete).

If the user deletes the link and then invokes ctrl-z to undo, nothing happens. It only works if the user clicks somewhere into the diagram or e.g. resizes the window. I guess this might be some kind of Focus Problem, because if I use an undo action button instead of the Keyboard shortcut, it works, thus the Information about the Change is there. We use the GoXam diagram hosted inside a Win Forms application (just in case this might be relevant).

Any idea why this might happen or even better, how to solve it?

Kind regards,
Marc

I don’t encounter that problem when deleting a link and then ^Z in any of the editing samples in GoWpfDemo.

Focus sounds like a reasonable cause. But I really don’t know what might be happening in your app.

Hi Walter,

I added some Debugging code which gives me the following Output:

lost keyboard focus new: System.Windows.Controls.ScrollViewer; old: Diagram:Diagram
deleting
lost keyboard focus new: System.Windows.Documents.AdornerDecorator; old: System.Windows.Controls.ScrollViewer

The first line is written when I select the link in the diagram. The last line is written when I deleted the link (either with Ctrl-Z or with an action).

When I click into the diagram again to make redo workable again, the first line is repeated. Thus I believe the Problem is that the ScrollViewer (which afaik is part of the Diagram control template) looses Focus to this AdornerDecorator after delete. I can Focus the diagram itself as Workaround, but I would prefer another solution because with focusing, the diagram is also displayed as focused with a dashed/dottet border.

Regards,
Marc

I suppose you could set the FocusVisualStyle to “{x:Null}”.

Cool. Works.

Thank you very much!

Marc