Our custom window will validate the First Name and the Last Name properties of the Customer object.First, check out the code below which will bind a new Custom object to the Data Grid View gv Add Customer.
The binding object has a validation tools collection which is used to hold the custom validation rules.
Finally, the binding is set to the Text Box control which is added to the Dock Panel control.
In this article we demonstrated how to create a WPF User Control which extends the functionality of a normal Text Box to add validation support.
Using the User Control we can easily add multiple validation rules to our Text Box control.
The above code will only validate successfully for numeric values.
Now let's implement a form which will make use of the custom requires Text Box User Control and validate against custom validation rules.
The User Control defined in the above code is a very simple control.
It consists of a Dock Panel control which contains a Label control.
The first thing that you need to do is to add a user control to your window.