Validating data in vb net
If the source of a two-way binding implements the interface and the Validates On Notify Data Errors property of the binding is set to true (which it is by default), the WPF 4.5 binding engine automatically monitors the Errors Changed event and calls the Get Errors method to retrieve the updated errors once the event is raised from the source object provided that the Has Errors property returns true.
Below is an example of a simple service with a single method that validates a username by first querying a database to determine whether it is already in use or not and then checks the length of it and finally determines whether it contains any illegal characters by using a regular expression.
WPF ships with two built-in concrete implementations of the object to the Validation.Provided that the view model has a property called “Name”, you bind it to a Text Box’s Text property in XAML the following way: Besides the path that specifies the name of the property to bind to, the binding must also have a source object.If you don’t specify a source explicitly by setting the Source property of the binding, it will inherit the Data Context from its parent element to use as its source.Setting the property to this value means that the value of the source property only gets updated when you explicitly call the Binding Expression. You will typically never use this approach in an MVVM application though.
If you want to bind a view model property of a specific type to a dependency property in the view of a different type you may need to implement a custom converter class by implementing the interface and setting the Converter property of the binding to an instance of this.could not be converted” when the conversion of the string value to an int fails, you may want to customize it.