This is for a WPF application.
Suppose I have an entity Post and I show a dialog to edit it. The dialog has Okay and Cancel buttons. The entity will be updated in the dialog. What if the Cancel button is clicked? How do I undo the changes? Obviously I can save each field and then restore each if the edit is to be canceled. Is there a more direct mechanism? The following is a simplified version of what I am doing.
Post
Post? post = Grid.SelectedItem as Post; if (post is null) return; EditPost ep = new(post); bool? b = ep.ShowDialog();