Steve Cook's WebLog

Extra entries on the undo stack

I spent some of this afternoon looking at a problem reported on the VSX forum.  The questioner has customized the designer and is getting multiple entries on the undo stack as a consequence of a single change.  I coded up his example, but in my case I only got a single entry on the undo stack.  What could the difference be?

The answer may be that there are custom event handlers which listen to store changes and create new transactions.  In the IMS, events are fired when a transaction commits, and are intended for synchronizing state outside of the store, most likely a user interface.  You should not create new transactions in an event handler, because if you do you will indeed get multiple entries on the undo stack.  If you want to synchronize one part of the store with another, you should use Rules: these cause changes to be propagated across the store within a single transaction.  Rules do not need to run on undo or redo, because the complete state of the store, including changes propagated via rules, is undone/redone in one go.

 

Published Monday, April 14, 2008 5:45 PM by Steve Cook
Filed under:
New Comments to this post are disabled

This Blog

Syndication

News

Locations of visitors to this page
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the author’s discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker