Securely Undoing the Command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I need to conditionally disable executing commands. The problem is that some of the conditions can only be checked after the command is fully executed.
I use the Idling event to be able to make my stuff at this very moment but I'm out of the ideas how to safely return to the state as it would be if the command hadn't ever be executed. I mean: I can undo the command by posting the PostableCommand.Undo and this would be fine but it activates the Redo option. The problem is that PostableCommand.Redo cannot be bound, otherwise I would just undo all the executions of Redo command (or even block it by binding its Execute() to an empty function) so I also cannot really rely on my Idling function to check whether Redo was indeed the last executed command and, if this is the case, undo it.
What is the recommended approach? Of course I assume that I would only use it where there is a point of having a state as if the command had never been executed, I don't want miracles like undoing deleting the file or printing it.