Discussion: We don't need INotifyDataErrorInfo for validation #7464
omikhailov
started this conversation in
General
Replies: 2 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Discussion: What's the practical point of supporting that interface?
Perhaps, in the times of first WPF releases the idea of highlighting textbox with red when validation fails was innovative and fresh, but today it is not enough. Validation should allow convenient customization of error messages with bindings, specialized controls and templates, but INotifyDataErrorInfo offers just event and a method to get information about errors. It would be much more convenient if it would provide bindable collection instead and would not be coupled with ViewModel.
In fact, most of the problems with validation can be solved quite simply if you would try to change the approach and instead of repeating old mistakes, start making new ones. For example, this is what I came up with after playing a couple of hours in the Visual Studio:
What in this code is better than in the ObservableValidator samples:
Below is the rest of the code required to better understand or compile this sample. It's all a draft, but it demonstrates that validation without INotifyDataErrorInfo can be simple and flexible, so I encourage you to consider whether WinUI should really support the old interface or consider other options. I am sure many people here can suggest better options.
Related Links
#179 Add Input Validation Support to WinUI (UWP and Win32 Desktop) with INotifyDataErrorInfo
ObservableValidator from Community Toolkit
INotifyDataErrorInfo
Beta Was this translation helpful? Give feedback.
All reactions