码迷,mamicode.com
首页 > 其他好文 > 详细

输入异常提示

时间:2017-12-31 21:11:42      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:log   bind   turn   取数据   binding   重复   set   source   div   

<TextBox Grid.Column="0"  Style="{StaticResource TextBoxStyle}" Height="30" Text="{Binding CodeBinding, Mode=TwoWay, ValidatesOnExceptions=True}"  Validation.ErrorTemplate="{StaticResource errorTemplateStyle}"></TextBox>
public string CodeBinding
{
    get
    {
        return code;
    }
    set
    {              
        SetProperty(ref code, value, () => CodeBinding);
        if (value==null)
        {
            return;
        }
        string sql = "";
        //读取数据库,看看编码是否重复
        var model=......;
 
        if (model!=null)
        {
            //编码重复,抛出异常
            throw new Exception("人员编码重复"); 
        }
    }
}

调试会报错,运行会显示错误警告"人员编码重复"

输入异常提示

标签:log   bind   turn   取数据   binding   重复   set   source   div   

原文地址:https://www.cnblogs.com/Lulus/p/8158364.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!