gpt4 book ai didi

c# - Windows Phone 7 文本框中的输入验证

转载 作者:行者123 更新时间:2023-11-30 17:21:14 25 4
gpt4 key购买 nike

我是 Windows Phone 7 开发平台的新手。我正在尝试对文本框输入进行验证。在调试时,如果输入无效,我会收到错误“未处理异常”。如何更正此错误?此代码适用于 silverlight 应用程序。

TextBox Text="{Binding Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" />

private string _name;
public String Name
{
get { return _name; }
set {

if (string.IsNullOrEmpty(value))
{
throw new Exception("invalid name");
}
_name = value;
OnPropertyChanged("Name");
}
}

最佳答案

您是否尝试过在尝试设置无效值时捕获无效名称 异常?

关于c# - Windows Phone 7 文本框中的输入验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3645193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com