プロパティの変更はPropertyChangedで通知されるが、Undoは以下の処理によりある程度の時間以内の変更は1つの処理として元に戻される。
/// <summary>
/// Tells the context that an action has occurred.
/// </summary>
/// <param name="action">The action that was executed.</param>
/// <param name="data">The data associated with the action.</param>
public void ActionExecuted(IUndoableAction action, object data)
{
object possible = null;
if (action is IUndoableProperty && (this.UndoStack.Count > 0 && this.UndoStack.First().Item1 == action.Name))
{
if ((DateTime.Now - lastModified).TotalMilliseconds < (action as IUndoableProperty).BatchingTimeout)
{
possible = this.UndoStack.Pop().Item2;
}
else
{
this.lastModified = DateTime.Now;
}
}
else
{
this.lastModified = DateTime.Now;
}
if (possible == null)
{
this.UndoStack.Push(new Tuple<string, object>(action.Name, data));
}
else
{
this.UndoStack.Push(new Tuple<string, object>(action.Name, possible));
}
this.RedoStack.Clear();
}