c# - WPF best way to compare edited value and original value -


Imagine that I have a textbox connected to the values ​​received from the database. And I have a cancel button. Something like the following:

  & lt; Text box text = "{binding [some viewsmodel] .stustara, mode = twain}" & gt; & Lt; / Textbox & gt; Now the value of  TestVar  is 10, and when the user has updated the price and press the cancel button, then I have a popup to tell the user Will show that  your data will be lost Are you sure you want to proceed?   

My idea is either using TextChanged or UpdateSourceTrigger = "PropertyChanged" to update a boolean flag and Check onclick on the Cancel button. But this thing is that the user is updating the value from 10 to 5, then back to 10? Then when the user clicks the cancel button, there should be no warning message.

Can I know what would be the most effective way of achieving the objective?

There are several ways to achieve this.

  1. Make a deep clone of your view-model and validate two integer values.

  2. Create a integer vodel with two fields

      // value Public int value {get; Set; } // Temporary Backup Value on Editing Public Ink Backup Value {Receive; Set; }      

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -