Wpf textbox validating event

Correspondingly, an underlying data value in the view model is automatically updated when the user modifies the bound value in the view.

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.

The condition will be as follows: is shown to the user and finally we are returning false; that is very important.

Importantance of returning false It's very important to use the return false statement after the condition block that return false so if validation determines that the business requirements are not met then the form cannot be submitted.

This post is about how data validation works in WPF and the different validation options there are available including implementing custom Validation Rules and using the In a typical WPF application that uses the MVVM (Model-View-View Model) design pattern, a dependency property of a user interface control in a XAML-defined view uses data binding to bind to some data returned by a CLR property of the view model.

Last modified 25-Sep-2016 16:08