【问题标题】:How to get numeric keyboard for Windows tablets?如何获得适用于 Windows 平板电脑的数字键盘?
【发布时间】:2019-02-28 15:05:34
【问题描述】:

我想要 Windows 平板电脑的数字键盘。我用了代码

Keyboard="Numeric"

但它为 Android 设备、iOS 设备和 Windows 手机提供数字键盘。它没有为 Windows 平板电脑带来数字键盘。我提到了this link,它说无法在平板电脑中使用数字键盘。我想知道有什么办法可以得到这个功能。也许使用自定义渲染器或依赖注入。如果有怎么办?

【问题讨论】:

    标签: windows xamarin.forms uwp keyboard


    【解决方案1】:

    这是已知问题,已在最新版本中修复,请将 Xamarin.Forms nuget 包版本更新为最新稳定版本(包含在 UWP 客户端项目中)

    更新

    [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();
                }
            }
        }
    }
    

    【讨论】:

    • 感谢您的回答!!!无论如何我可以在不更新我的 Xamarin 表单包的情况下执行此操作吗?
    • 当然,你可以像上面那样自定义条目渲染器。
    • Zhu 可以得到只显示数字的键盘吗?现在我同时使用电话和数字键盘,但它也显示特殊字符。
    • emm, 键盘是系统提供的,我在平板电脑中没有找到纯数字键盘。所以,我认为它不能显示纯数字。
    猜你喜欢
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 2012-10-12
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多