在UWP中验证控件的最简单方法是什么? [英] What is the simplest way to validate the controls in UWP?

查看:74
本文介绍了在UWP中验证控件的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发UWP应用程序,因为我是这个平台的新用户我完全不知道如何验证UWP应用程序中的XAML控件。



我尝试过:



我正在开发UWP App,因为我是这个平台的新手我完全不知道如何验证XAML UWP App中的控件。

I'm developing UWP App as I'm new to this platform I'm totly un aware how to validate XAML controls in UWP App.

What I have tried:

I'm developing UWP App as I'm new to this platform I'm totly un aware how to validate XAML controls in UWP App.

推荐答案

验证控件是什么意思?验证控件的数据,而不是XAML控件。您可以这样做,例如,

What do you mean by validating the controls? The data of the controls is validated, instead of the XAML controls. You can do so, such as,
<textbox name="username" />



假设您必须验证用户必须输入长度为5-25的用户名。您可以使用C#代码验证输入(如果使用该语言,则使用VB.NET),


Suppose you have to "validate" that the user must enter the username to be of length 5-25. You can validate the input using the C# code (or VB.NET if you are using that langauge),

string inputData = username.Text; // Get the text

// Validate
if(inputData.Length < 5 || inputData.Length > 25) {
   // Notify the user about the error
}



同样,您可以对正在使用的控件执行其他检查,您可以使用它们的属性值,然后检查它们你想要的价值观。



Jerry Nixon刚刚写了一篇关于它的帖子, Jerry Nixon在Windows上:让&#8217;代码!在Windows应用商店应用中处理验证(WinRT-XAML)。 [ ^ ]


这篇关于在UWP中验证控件的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆