Imagine that I have a textbox that bind to a value retrieved from database. And I have a cancel button.Something like below:
<TextBox Text="{Binding [someViewModel].TestVar, Mode=TwoWay}"></TextBox>
Now says TestVar
's value is 10 and when user updated the value and press the cancel button, I will show a popup to tell user that your data will be lost. Are you sure you want to proceed?
My idea is using either TextChanged
or UpdateSourceTrigger="PropertyChanged"
to update a boolean flag and upon cancel button onclick
do the checking. But the thing is if user updated the value first from 10 to 5, then back to 10? Then when user press the cancel button, there should be no alert message.
May I know what would be the most efficient way to achieve the objective?