I have created a calculator like function to allow the user to update all cells in a given column. I loop through each cell in the column and change the value based on user input. What I would like is to have the ability for the user to undo what was done to each cell in one undo click. Is this possible with the built in undo button, or would a custom undo be required? If the latter, what properties should I be looking at to make it work?
Hello,
What you can do is call the DataPresenterCommands.Undo as many times as the number of changes you have made. However, currently there is no property exposed on the XamDataGrid to know how many actions you should undo (please note that actions like resizing, etc can also be undo-ed).
private void button1_Click(object sender, RoutedEventArgs e)
{
xdg.ExecuteCommand(DataPresenterCommands.Undo);
}
You could create a custom code that will keep track of this.
You may also want to submit a feature request for adding a property or a collection, showing how many actions can be undo-ed here.
It seems that the code:
will not undo a cell change if I change the cell in code with something like:
Cell targetCell = GetCellToChange();
targetCell.Value = newValue;
but it will undo a cell change if I manually type in the cell.