Can I rollback collection changes on collection changed event?

后端 未结 3 1391
你的背包
你的背包 2021-02-15 03:36

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 particula

3条回答
  •  佛祖请我去吃肉
    2021-02-15 04:05

    Considering you get the sender of the event as an object (ie. the first parameter of the event) and the list of objects that were modified, yes you can do that. I wouldn't advise that though. If you encounter such a condition, provide a method on the ViewModel which is provided with the EventArgs, and let it do the work. The view isn't the place to do logic.

    Even better: check for the condition in the ViewModel itself (ie in the commands that are responseable for adding/removing)! The viewmodel is responseable for the state of the information, so keep your logic there. The view is just there to display the data.

提交回复
热议问题