我有一个 PCL,它将我的 MVVM 页面存储在 XAML 中。我在 XAML 文件中有以下内容,但我想禁用键盘上的自动完成功能。有谁知道我如何在 XAML 中做到这一点?
<Entry Text="{Binding Code}" Placeholder="Code" />
最佳答案
定制 Keyboard
可以使用 x:FactoryMethod
在 XAML 中创建实例属性。您可以使用以下标记实现您想要的:
<Entry Text="{Binding Code}" Placeholder="Code">
<Entry.Keyboard>
<Keyboard x:FactoryMethod="Create">
<x:Arguments>
<KeyboardFlags>None</KeyboardFlags>
</x:Arguments>
</Keyboard>
</Entry.Keyboard>
</Entry>
KeyboardFlags.None
从该字段中删除所有特殊键盘功能。Multiple enums可以在 XAML 中通过用逗号分隔它们来指定:
<KeyboardFlags>CapitalizeSentence,Spellcheck</KeyboardFlags>
当您不需要自定义时
Keyboard
,您可以使用 one of the predefined ones利用 x:Static
属性:<Entry Placeholder="Phone" Keyboard="{x:Static Keyboard.Telephone}" />
关于xaml - 在 Xamarin.Forms PCL XAML 页面中禁用自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26966404/