本文共 1795 字,大约阅读时间需要 5 分钟。
ylbtech-SilverLight-DataBindings_BindingADataObjects_Validation:一、银光验证。ValidatesOnExpression和NotifyOnValidationError |
1.A,数据源 |
4,
1.B, ValidatesOnExpression |
2.3/3,
2B, Person.cs
int _age; //范围////// 年龄/// public int Age{ get { return _age; } set { if (value < 0) throw new ArgumentException("不能小于0"); _age = value; }}
3,
1.C, NotifyOnValidationError |
2.3/3,
using System.Windows.Controls;using SL3ValidationYlbtechApp.Access;namespace SL3ValidationYlbtechApp.DataBinding.BindingADataObjects.Validation{ public partial class NotifyOnValidationError : UserControl { public NotifyOnValidationError() { InitializeComponent(); gridDetailPerson.DataContext = Person.GetModel(); } private void gridDetailPerson_BindingValidationError(object sender, ValidationErrorEventArgs e) { //显示错误 txtBlkTip.Text = e.Error.Exception.Message; txtBlkTip.Text += "\n存储值:" + ((Person)gridDetailPerson.DataContext).Age; //建议用户再试一次 txtAge.Focus(); } }}
3,
1.D, |