Custom textbox validating user input in Sex chat without creating any account

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.

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.

Below you can see the screenshot of the validation rules in action which you tab of the Text Box control without entering any value. We can also easily customize and add new rules by inherting from the Validation Rule class.

Let's check out another validation rule which forces a developer too type a numeric input into the Text Box.

Our mission is to validate the Text Box on lost focus event hence, we are going to implement the Text Box lost focus event.

Inside the lost focus event we are extracting the binding expression from the Text Box control and updating the source.

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.

Leave a Reply