Last Updated:
15 Dec 2020 13:32
by ADMIN
I have user control which is used to edit a certain entity on my system - say a person. It has several text boxes to exit various properties and they are all linked to a ValidationProvider with rules. That UC is loaded on a form. The user of my software can choose which person to edit from a list and he/she can choose to edit multiple person entities in a row. So here is where I have a problem:
User clicks on Person1 and the UC with ValidationProvider is shown. Say the user clears a textbox which results in validation error - the textbox will be marked with red. Now if the user switches to edit another entity (Person2), the program does not create a new UC but instead it reuses the existing UC and sets the values of the textboxes to the values of Person2. But because the previous edit has a validation error but red textbox will still remain red. This is where the problem is. The only way to remove the error state is to trigger validation again but that cannot happen until the user start typing which is not the desired behavior.
It would be really helpful to have a method on the ValidationProvider to clear the invalid states of all linked controls - resetting them to the default state. That when whenever the user switches to edit Person2, I can reset the states of the controls so that the error from the previous edit disappears.
Currently I have worked around the problem by creating a new instance of the UC for each edit but that might not be ideal if you have a somewhat large edit form and you need to refresh it very quickly.