I have 2 list views…and add/remove buttons between them.
On collection changed event of a list-view-collection in viewmodel, can i rollback the changes for a particular condition ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could handle the
CollectionChangedevent of theObservableCollectionto backup (via the VM or whatever) the old values (seeNotifyCollectionChangedEventArgs.OldItemsproperty) and get them back when needed i.e. when user clicks ‘Undo’ etc.Update In reference to comments bellow:
If you do want to rollback the collection from withing the
CollectionChangedevent-handler, create a flag where you escape the handler from a recursive call (not tested with multi-threaded application), here is a simple example, you can easily tweak it to fit in your V/VM.