8,757
社区成员
发帖
与我相关
我的任务
分享
private string userName;
public string UserName
{
get { return userName; }
set
{
if (MainPage.isVal)
{
if (string.IsNullOrEmpty(value))
{
throw new Exception("用户名不能为空.");
}
userName = value;
OnPropertyChanged("UserName");
}
}
}
/// <summary>
/// 验证
/// </summary>
/// <returns></returns>
public bool Validate()
{
bool result = false;
//用户名
BindingExpression coverName = textBox1.GetBindingExpression(TextBox.TextProperty);
coverName.UpdateSource();
if (Validation.GetHasError(textBox1))
return result;
return true;
}
if (Validate())
{
}
isVal = false;
BindingExpression name = textBox1.GetBindingExpression(TextBox.TextProperty);
name.UpdateSource();