views:

43

answers:

1

I have a childwindow with a number of Textboxes, Comboboxes, and DatePickers. I want to know if a user has changed any value in these (to know if I need to save to db)

One way I could think of doing this are in the 'on chg' event handlers and set bool. But if a user changes the value, in say a combobox, then changes back to the original this would still be seen as a change.

Are there other alternatives?

(note the project is not set up as MVVM)

Thanks

A: 

If you don't use mvvm but still bind to an object then:

  • before the window is shown create a copy of the object, save it, and bind it to DataContext
  • whenever you need to know if user made any changes you can compare the saved object to DataContext (property by property)

I you don't use binding at all then:

  • before the window is shown save all fields that can be modified to a Dictionary
  • whenever you need to know if user made any changes you can compare the dictionary values to values of the fields
PL