Drag and Drop Operation Resets the Undo Stack for a Textbox
I have an issue with the Undo stack being destroyed when doing a drop operation on a TextBox.
Reflector didn't give any insights on how the TextBox handles the Undo stack in this state.
I also see no way to control this Undo stack at all, that it is completely internal. I've seen the MS folks say much the same over at the开发者_Python百科 MSDN forums.
Anyone have any ideas on how to prevent a drop action on a Textbox from destroying its Undo history stack?
This isn't quite answering your question, but you could manage your own undo stack for the textbox. There are a number of Undo frameworks to help in this area, or you could roll your own if this is the only textbox that needs custom undo.
I happen to maintain one of these undo frameworks on Codeplex. The "Monitored Undo Framework" watches for changes to the data, stores the changed values, and provides simple methods for undoing / redoing these changes.
I have looked at the implementation of the TextBox in reflector too. The code is not trivial and appears to traverse a pretty large codebase for text handling. As far as I know, the only knob available for tweaking a textbox's Undo is to turn undo on / off. Beyond that, it seems to be a black box.
精彩评论