Is it possible specify Xamarin Forms Entry Numeric Keyboard without comma or decimal point separator?

To restrict the Entry to only accept numbers you could use a Behavior or a Trigger.

Both of those will react to a user typing into them. So for your use, you could have the trigger or behavior look for any characters that are not numbers and remove them.

Something like this for a behavior (note that I wrote all this on SO and did not try compiling it, let me know if it does not work):

using System.Linq;
using Xamarin.Forms;

namespace MyApp {

    public class NumericValidationBehavior : Behavior<Entry> {

        protected override void OnAttachedTo(Entry entry) {
            entry.TextChanged += OnEntryTextChanged;

        protected override void OnDetachingFrom(Entry entry) {
            entry.TextChanged -= OnEntryTextChanged;

        private static void OnEntryTextChanged(object sender, TextChangedEventArgs args) 

                 bool isValid = args.NewTextValue.ToCharArray().All(x=>char.IsDigit(x)); //Make sure all characters are numbers

                ((Entry)sender).Text = isValid ? args.NewTextValue : args.NewTextValue.Remove(args.NewTextValue.Length - 1);


Then in your XAML:

<ContentPage xmlns=""
         xmlns:local="clr-namespace:MyApp;assembly=MyApp"> <!-- Add the local namespace so it can be used below, change MyApp to your actual namespace -->

  <Entry x:Name="AgeEntry"
      <local:NumericValidationBehavior />


Leave a Comment