0

I need to enable the user to enter negative values in my xamarin application entry fields fro IOS project. Currently i use the following custom renderer to use the NumbersAndPunctuation keypad. But i do not want an alphanumeric keypad for entrering only numeric inputs. Is there a better solution for the same?

public class NumericKeypadRenderer: EntryRenderer
  {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control == null) return;

        
          Control.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            
        }
    }

Is there a way to just add a minus button to the numeric keypad in IOS?

Hari
  • 15
  • 2
  • 1
    Either create your own keyboard to show, or use what the platform provides you. What the platform provides you is not customizable to this extent where you can add custom buttons and actions, except for changing the behavior of the "enter" button. – Cheesebaron Jun 21 '21 at 06:58

1 Answers1

0

We can't only add a custom button on the default keyboard. We need to customize the keyboard to achieve that.

You could follow this thread to create your keyboard:Custom Keyboard in Xamarin forms

There is an sample in this link, you could refer to his customrenderer : https://github.com/Eren-Shen/CustomKeyboardDemo/tree/master/CustomKeyboardDemo/CustomKeyboardDemo.iOS

Leo Zhu
  • 15,726
  • 1
  • 7
  • 23