[英]Variable length in Xamarin Community Toolkit MaskedBehavior
I'm trying to use the Xamarin Community Toolkit MaskedBehavior
in my app for phone extensions which can be 2, 3 or even up to 6 digits long.我正在尝试在我的应用程序中使用 Xamarin 社区工具包MaskedBehavior
进行电话分机,其长度可以是 2、3 甚至最多 6 位数字。
It's easy to define the mask if it's a set length but how do I use it in this case where I want the user to enter only numeric values but the length can be anywhere from 2 to 6 digits?如果掩码是固定长度,则很容易定义掩码,但在这种情况下我如何使用它,我希望用户仅输入数值但长度可以是 2 到 6 位数字?
<Entry
Placeholder="Ext"
Text="{Binding Extension}"
Keyboard="Numeric">
<Entry.Behaviors>
<xct:MaskedBehavior
Mask="X?????"/>
</Entry.Behaviors>
</Entry>
Turns out, I don't have to do anything.事实证明,我不需要做任何事情。 When I set the mask as Mask="XXXXXX"
, it will accept any number of digits up to 6. It doesn't force the user to always enter six digits.当我将掩码设置为Mask="XXXXXX"
时,它将接受最多 6 位的任意数字。它不会强制用户始终输入六位数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.