Restrict Certain Characters in Entry Control

Xamarin Blog Post Image Logo

Often times while building mobile apps in Xamarin.Forms you get a requirement to restrict certain characters in input, this is not provided in Xamarin.Forms out of the box to disable certain characters in Entry control but Xamarin provides Behaviors which we can apply on Entry controls and achieve the desired result.

First of all lets create a sample project and add an Entry to our page.

Behavior in action, you can see in demo below that entry control is not allowing us to enter restricted characters:

Behavior in action

Behaviors in Xamarin.Forms are very powerful feature of adding functionality to UI controls without have to subclass them. You can read more about behavior here.

View All Articles