Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 限制在xamarin表单中只输入数字和句号_C#_Xamarin_Xamarin.forms - Fatal编程技术网

C# 限制在xamarin表单中只输入数字和句号

C# 限制在xamarin表单中只输入数字和句号,c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,我有一个条目,我只限制为数字(它不能接受任何其他符号或字母),现在我希望它只接受句号(.) 这是将输入限制为仅数字的代码 private static void OnEntryTextChanged(object sender, TextChangedEventArgs args) { if (!string.IsNullOrWhiteSpace(args.NewTextValue)) { bool isValid = args.

我有一个条目,我只限制为数字(它不能接受任何其他符号或字母),现在我希望它只接受句号(.)

这是将输入限制为仅数字的代码

private static void OnEntryTextChanged(object sender, TextChangedEventArgs args)
    {

        if (!string.IsNullOrWhiteSpace(args.NewTextValue))
        {
            bool isValid = args.NewTextValue.ToCharArray().All(x => char.IsDigit(x)); //Make sure all characters are numbers

            ((Entry)sender).Text = isValid ? args.NewTextValue : args.NewTextValue.Remove(args.NewTextValue.Length - 1);
        }
    }

有人能帮忙吗?谢谢。

我怎么会错过这个!!谢谢……)
bool isValid = args.NewTextValue.ToCharArray().All(x => char.IsDigit(x) || x.Equals('.'));