Imagine this: you have a Master-Child window consisting of a list of items (the Master window) and a set of controls where you can edit the currently selected item (the Child Window). The child window has "Apply" and "Cancel" buttons.
A user begins editing values. He then changes the selection, before pressing the "Apply" button.
Your application displays a message "Apply changes to the current item?", with the buttons being "Yes", "No" and "Cancel". If the user presses "Cancel" then the attempt at changing the current selection should fail.
The "CurrentSelection" item is databound.
I thought I could deal with this in the "setter" part of the CurrentSelection
property. If the user selects "Cancel", I simply keep the CurrentSelection
item as it is, and fire a PropertyChanged
notification event to tell the form to update back to the old selected item. The control is ignoring this notification event. (Which makes sense, the Control is saying "I know the current selection has changed. I just changed it!")
Any ideas how to fix this? In summary, the control tries to change the bound SelectedItem
, and I want to tell it "No you can't change this selected item right now".
And to do what Kent Boogaart pointed out, refer to this reply..
How to stop a WPF binding from ignoring the PropertyChanged event that it caused?
This sounds like you are looking for the memento pattern:
http://en.wikipedia.org/wiki/Memento_pattern
Hope this helps.
Just a thought without having tested it: try raising the property changed event in a separate message. The list probably has a latch to ignore any notifications whilst it's changing the property value. If you dispatch a separate message that contains the notification, the latch should be reset and it should handle it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With