Hi,
What are the best practices or tips with respect to data binding to objects?
I have a complex data binding scenario where my winform has a BindingSource set to an object. This object is a class of type Customer and the forms are bound the customer's properties like "firstName", "lastName", etc.
Each property has the following pattern (pseudo-code)
- get: return mProperty
- set: mProperty = value; PropertyHasChanged()
Some changes to certain properties requires automatically setting other values. For example:
- Choosing a country will load a second dropdown with a list of states/provinces
- Checking a checkbox (databound to a boolean property) will set the country and state/province to specific values
Where do I put the code that will set the country and state/province based on the checkbox? If I set the properties in the wrong order, (province before the country) the change to the country will force a change of the province list and override the selected province since it won't be in the list (this is a trivial example, but reflects the timing issues).
What are the best practices or tips with respect to data binding to objects?