xamarin.forms - Xamarin Forms 数字键盘 - 启用空格和破折号按钮

标签 xamarin.forms xamarin.android

我有一个要求,允许 Xamarin Forms 应用程序中的字段仅包含数字、空格和破折号。数字键盘布局似乎非常适合此目的 - 唯一的麻烦 - 空格键和破折号按钮似乎不起作用?有什么方法可以启用这些,特别是在 Android 上——因为这是主要的目标平台。

有问题的按钮被突出显示。

<Entry
                            x:Name="BarcodeEntry"
                            Margin="12,0"
                            HeightRequest="40"
                            Placeholder="Barcode"
                            Style="{StaticResource BorderlessEntryStyle}"
                            Keyboard="Numeric"
                            Text="{Binding Barcode.Value, Mode=TwoWay}">

控件绑定(bind)到这个属性:

private string _barcode;
        public string Barcode
        {
            get => _barcode;
            set { SetProperty(ref _barcode, value); }

enter image description here

最佳答案

对于数字键盘,我们只有四种相关的 InputType。

  • number:一个纯数字字段。
  • numberDecimal:可以与 number 及其其他选项结合使用以允许使用十进制(小数)数。
  • numberPassword:数字密码字段。
  • numberSigned:可以与 number 及其其他选项结合使用以允许签名数字。

有关输入类型的更多详细信息,您可以引用下面的链接。 https://developer.android.com/reference/android/widget/TextView#attr_android:inputType

如果您想使用空格和破折号按钮,您可以使用电话键盘。或者您可以创建自己的自定义键盘。

自定义键盘:Numeric keyboard as default on Xamarin.Forms, but allow text (cross platform)

关于xamarin.forms - Xamarin Forms 数字键盘 - 启用空格和破折号按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69640492/

相关文章:

c# - xamarin 在平板电脑和大屏幕中形成拉伸(stretch) View

android - 在上下文操作中使用导航会引发异常

android - 在 Android 的外部存储中创建目录失败

xamarin - 在 Xamarin Studio 中找不到类型或命名空间名称 'Page'

ios - Xamarin.Forms - 图像未显示在 iOS 上的 ImageButton 中

mobile - Xamarin WebView 请求桌面站点

c# - Xamarin Studio 的构建选项尚未完全实现

c# - Xamarin无法连接到mysql

xamarin - 如何从 Xamarin Android C# 项目调用返回字符串选项的 PCL 中的 F# 方法?

ios - 当我尝试访问已恢复的 CoreBluetooth 外围设备时,Xamarin iOS 应用程序崩溃