For reference, conceptually, look at the configuration and add behaviors with the correct keyboard, no matter the Idiom.
One observation, however, is that these only seem to work for Android. For iOS, the NumbersAndPunctuation keyboard always appears, despite validation of assignment in the renderer and UWP does not appear to honor the
InputScope designation (comes in null) for the control - even with the known limitations with keyboard customization.
Android
/// <inheritdoc />
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e)
{
base.OnElementChanged(e);
if(this.Control == null)
{
return;
}
this.Control.InputType |= Android.Text.InputTypes.ClassNumber;
if (this.Control.MaximumNumberDecimalDigits > 0)
{
this.Control.InputType |= Android.Text.InputTypes.NumberFlagDecimal;
}
if (double.TryParse(this.Control.Minimum?.ToString(), out var minimum) && minimum < 0)
{
this.Control.InputType |= Android.Text.InputTypes.NumberFlagSigned;
}
}
iOS
/// <inheritdoc />
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e)
{
base.OnElementChanged(e);
if (this.Control == null)
{
return;
}
// Left verbose for readability - changing to DecimalPad or NumberPad seems to have no effect as the keyboard always seems to be NumbersAndPunctuation
this.Control.KeyboardType = UIKit.UIKeyboardType.NumberPad;
if (this.Control.MaximumNumberDecimalDigits > 0)
{
this.Control.KeyboardType = UIKit.UIKeyboardType.DecimalPad;
}
if (double.TryParse(this.Control.Minimum?.ToString(), out var minimum) && minimum < 0)
{
this.Control.KeyboardType = UIKit.UIKeyboardType.NumbersAndPunctuation;
}
}
UWP
/// <inheritdoc />
protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e)
{
base.OnElementChanged(e);
if (this.Control == null)
{
return;
}
var scope = new InputScope();
scope.Names.Add(new InputScopeName() { NameValue = InputScopeNameValue.Number });
// Comes in as null, doesn't appear to affect the keyboard presented with Windows tablet.
this.Control.InputScope = scope;
}