How to cancel an edit to an object using MVVM?

后端 未结 7 1566
既然无缘
既然无缘 2020-12-01 08:34

How can I implement cancelation of editing an object using MVVM.

For example: I have a list of customers. I choose one customer an click the button \"Edit\", a dialo

7条回答
  •  佛祖请我去吃肉
    2020-12-01 08:58

    Based on Камен Великов's answer:

    You can mark your bindings as to be updated manually by defining

    in your view (XAML). Then, you have to write the changes from your UI in ViewModel by calling

    yourTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
    when Save is clicked.

    Please note, if there are updated to the binding source triggered from anything else, they are still shown directly in the UI.

提交回复
热议问题