I want numeric keyboard for Windows tablets. I used code
Keyboard="Numeric"
but it gets numeric keyboard for Android devices, iOS devices and Windows phone. It doesn't bring numeric keyboard for Windows Tablet. I refered this link (https://stackoverflow.com/questions/46413795/how-to-change-the-keyboard-layout-of-a-uwp-app-in-xamarin-forms) it says that getting a numeric keyboard in tablet is not possible. I want to know is there any way I can get this feature. Maybe using custom renderer or dependency injection. If so how?
I used this renderer code and it worked like a charm
[assembly: ExportRenderer(typeof(Entry), typeof(MyEntryRenderer))] namespace App10.UWP { public class MyEntryRenderer : EntryRenderer { protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); if (Control != null) { Control.InputScope = Element.Keyboard.ToInputScope(); } } } }
Answers
@judsonabraham
My tablet battery is dead at the moment, but using a soft/touch keyboard (enabled in the Windows accessibility settings), I have tested the following on my Windows desktop, which works. I would assume that it would also work on a tablet.
The standard Xamarin.Forms.Entry properties do not support what you want. Use a custom Entry renderer to tweak the Windows FormsTextBox control, as follows. In this code nativeTextField is the FormsTextBox.
Windows being Windows, there is more than one type of soft keyboard that can appear. The above code works for the "touch keyboard, or Soft Input Panel (SIP)". However, there is a separate On-Screen Keyboard which is a separate program, and the above does not change that. That sounds like a change Microsoft needs to make in a future release of Windows. For more info, see https://docs.microsoft.com/en-us/windows/uwp/design/input/use-input-scope-to-change-the-touch-keyboard
I used this renderer code and it worked like a charm
It depends on how fine-grained control you want over what a "numeric" keyboard looks like.
As per https://forums.xamarin.com/discussion/comment/366351/#Comment_366351
the following values will give you finer-grained control: