验证控制组件功能增强,支持多验证器

原先系统中只能对一个控件添加一个验证器如:长度、数值、非空,而项目开发有需要同时用多个验证器的情况如:在验证长度时也要验证非空。

xmlns:p="clr-namespace:Glodon.Presentation.Validators;assembly=Glodon.Presentation"

.....

<TextBox  Name="txtName" Height="23" Text="{Binding PersonObject.Name,Mode=TwoWay}"    Style="{StaticResource textBoxStyle}">

    <p:ValidatorService.MultiValidators>

        <p:ValidatorCollection>

            <p:LengthValidator RequireIndicator="False"  MaxLength="10" ManagerName="Group1" ErrorMessage="最多只能输入10个汉字" />

            <p:RequiredValidator RequireIndicator="False"  IsRequired="True" ManagerName="Group1" ErrorMessage="姓名栏不能为空"/>

         </p:ValidatorCollection>

   </p:ValidatorService.MultiValidators>

</TextBox>

 

posted @ 2012-10-15 13:00  红萝卜  阅读(252)  评论(0编辑  收藏  举报