使用dataInput:DescriptionViewer对输入的数据进行校验

使用此功能时,主要分为两步:

1、在数据校验字段中,添加用于界面显示的标识:

        [Display(Name="登录名称", Description="输入登录名称")]
        [Required(ErrorMessage="请输入登录名称")]
        public string loginName{}

 

如果未添加此标识,显示时:loginName 为必需字段

2、设置显示的方式:

<TextBox Height="23" Name="textBox1" Text="{Binding pcode, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Grid.Row="1" Grid.Column="1" />
<dataInput:DescriptionViewer Name="dvLoginName" Grid.Row="1" Grid.Column="2" Target="{Binding ElementName=user}" PropertyPath="pcode" />

//显示出错汇总
<dataInput:ValidationSummary Grid.Row="5" Grid.Column="1"/>

 

显示结果:

a

posted on 2011-12-23 07:02  龙少爷  阅读(291)  评论(0编辑  收藏  举报

导航