Hi team,
I have just started using your Xamarin SfDataForm, and must say I'm impressed with the functionality out of the box.
My application is Xamarin Forms using Prism / Unity, and I have been able to configure the DataForm mostly to my liking, but have a couple of issues that I've been unable to solve that I'm hoping you can help with.
1. Validation
I have a view containing a DataForm, with its DataObject set to the underlying view model and several DataFormTextItem elements defined for properties exposed by the view model. Validation is set up using Data Annotations, and I have observed an issue where validation occurs immediately for properties directly on the view model, but validation of properties of child objects does not occur immediately when the text is changed.
2. Bound data not updated
In the same view, if any of the underlying data changes the corresponding field in the DataForm is not updated. The properties all implement INotifyPropertyChanged which can be proven by the observing the same properties bound to normal Entry controls in the same view.
I have attached a sample solution that illustrates these issues.
Steps to observe difference in validation behavior:
- Launch UWP application
- Delete the text in the View Model Username field
- Note that the validation error message is shown when the last character is deleted
- Delete the text in the Child Object Username field using the Backspace key
- Note that the validation error message is NOT shown when the last character is deleted
- Set focus to a different field - validation error message still NOT shown
- Set focus to Child Object Username field - validation error message still NOT shown
- Set focus to a different field - this time validation error message IS shown
- This only appears to affect nested properties of objects in the view model.
Steps to observe bound data not updating:
- Launch UWP application
- Note that the values of View Model Username, Child Object Username, View Model Username (Direct Binding) and Child Object Username (Direct Binding) all show the text "Delete Me"
- Click the Toggle Usernames button
- Note that View Model Username (Direct Binding) and Child Object Username (Direct Binding) are cleared, but the data form fields View Model Username and Child Object Username are not
- To prove that they are bound to the same objects, begin deleting characters from the data form field View Model Username
- Note that View Model Username (Direct Binding) is updated as each character is deleted
- To observe delayed update for the child object, begin deleting characters from the data form field Child Object Username
- Note that Child Object Username (Direct Binding) is NOT updated
- Set focus to a different field
- Note that Child Object Username (Direct Binding) IS now updated
- You can also observe that the binding and validation are updated at different times by deleting all the text from Child Object Username and setting focus to a different field, which updates Child Object Username (Direct Binding) but does NOT show the validation error message
- Set focus on and off Child Object Username and the validation error message is eventually updated
To work around the validation issue I have implemented display properties in the view model which are mapped from and to the child object during load and save respectively. This could be argued to be better design by taking validation out of the model, but I do feel that the underlying issue needs looking at.
For the binding issue I have not come up with a work around, as I only spotted this while testing the validation issue, and it does not affect my application as yet.
Kind regards,
James
Attachment:
DataFormIssues_167750f9.zipx