SL4.基本数据验证
2011-08-24 17:05
92 查看
XAML:
Book.CS:
<StackPanel> <Button Name="MyButton" Content="Update" Click="MyButton_Click" Width="65" Height="41"></Button> <TextBlock Height="23" Name="tbtitle" Text="{Binding Title,Mode=OneTime}" /> <TextBlock Height="23" Name="tbtitles" Text="{Binding Title,Mode=OneWay}" /> <TextBox Height="23" Name="tbprice" Text="{Binding Path= Price,Mode=TwoWay,ValidatesOnDataErrors=True}" Width="150"/> </StackPanel>
Book.CS:
private decimal _price; public decimal Price { get { return _price; } set { if (_price != value) { if (value<0) { _dataErrors["Price"] = "价钱不能小于0"; } else { if (_dataErrors.ContainsKey("Price")) { _dataErrors.Remove("Price"); } } _price = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Price")); } } } } private string _dataError = string.Empty; public string Error { get { return _dataError; } } private Dictionary<string, string> _dataErrors = new Dictionary<string, string>(); public string this[string columnName] { get { if (_dataErrors.ContainsKey(columnName)) return _dataErrors[columnName]; else return null; } }
相关文章推荐
- django(7)modelform操作及验证、ajax操作普通表单数据提交、文件上传、富文本框基本使用
- 在Silverlight中进行基本的数据验证
- 1 开发一个注重性能的JDBC应用程序不是一件容易的事. 当你的代码运行很慢的时候JDBC驱动程序并不会抛出异常告诉你。 本系列的性能提示将为改善JDBC应用程序的性能介绍一些基本的指导原则,这其中的原则已经被许多现有的JDBC应用程序编译运行并验证过。 这些指导原则包括: 正确的使用数据库MetaData方法 只获取需要的数据 选用最佳性能的功能 管理连
- 在Flash中调用WS时的身份验证_3:基本数据类型
- 【Java】【TIJ】验证Java对类的基本数据类型的成员的默认初始化结果
- python+httplib实现HTTP POST提交数据,使用Basic Authentication(基本验证)做登陆验证
- 基本数据类型验证
- java中的8种基本数据类型占的位数以及取值范围
- 基本数据类型
- JDBC实现数据库的几种基本操作(查询,分页查询,根据关键字进行查询以及插入数据)
- Java 基本数据类型
- C语言的基本数据类型长度
- java数据类型总结--基本+引用
- Java学习笔记----打印基本数据类型范围
- 数据挖掘--决策树基本应用实例
- java基本数据类型
- C语言--基本数据类型1
- 8.Python的基本数据类型(下)
- 【嵌入式Linux C编程】2018.3.8 数据类型、运算操作符、基本语句
- 验证52域数据是否被篡改且根据52域算出密码