I have a DataForm from System.Windows.Controls.Data.DataForm.Toolkit and I need to programmatically get the same result as after clicking Cancel on this DataForm.
I need that because this DataForm is in ChildWindow, and if I change something in DataForm and I close a ChildWindow, then changes will be commited. This shouldn't work in that way. When I close ChildWindow I want to discard all changes the same as after clicking Cancel Button.
I've tried
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
dfColumnInfo.CancelEdit();
base.OnClosing(e);
}
but it doesn't work.
Thank you in advance.
bugfinder suggested to add a code which saves changes. There is no such thing, because childWindow has an editedObject as a DataContext
childWindow.DataContext = table;
childWindow.MyDataForm.DataContext = table.Items;
childWindow.Show();
I don't know how how, but Cancel button of DataForm reverts all changes which I've done in DataForm, which is a great think. But how to get the same effect by using some other button of childWindow, or just by closing childWindow?