I need to do some kind of data validation in a WPF application I am developing
As far as I know, when you add ValidatesOnDataErrors=True
to the Binding, everytime the Binding is resolved (it can be every time teh value changes, it can be when focus is lost), Binding engine checks the binding source, through IDataErrorInfo
, access the interface, finds out if there is some error or not.
It sounds good, with only one caveat. In order for data to be validated, it needs to be rendered. If you happen to have an ObservableCollection
of that entity bound to a ListBox
with VirtualizingStackPanel.IsVirtualizing=True
, only rendered items are validated. Since most items are outside viewport, they are not rendered.
How can I force every item to be validated? Removing UI virtualization is not an option.