Reputation: 147
How to declare a BindingSource in VB using WPF? I can't use a command like BindingSource.CancelEdit() like I used to when using Windows Form instead of WPF...
Upvotes: 0
Views: 1872
Reputation: 2944
You could use a BindingGroup for that: set a BindingGroup on an element in XAML which contains all the controls that edit your object. By default, this will set the UpdateSourceTrigger on these controls to Explicit, which means that you will have to call BindingGroup.UpdateSources in order to actually change the properties of the object which is currently edited. So, you would do that in a Submit command or something similar.
If you want to cancel the edit, you can do that using BindingGroup.CancelEdit. This will throw away the cached values in the controls and reset them to the values of the bound properties.
I think this is a lot easier than implementing IEditableObject or a Memento...
Upvotes: 2
Reputation: 1325
The short answer is not good news - the isn't an equivalent method. Instead your approach needs to be a little different. One approach would be to implement the IEditableObject on your underlying class (or wrap it in an editable class). The second would be to implement Undo/Redo functionality. I think you will find searching for the terms bolded above and/or the memento pattern you will find lots of good examples, below is one.
Cancelling an update with WPF Binding
Upvotes: 1