Sunday, 15 May 2011

c# - saving not validating properties -


There is a strange need in my project. I have to use the verifier on that field which is binding for the view and on the setter -The property change method. This is done:

  Public class MyValidationRule: Validation rule {Private const int MyLength = 17; Public override validation object (Object Value, CultureInfo Culture Infosa) {var valueString = (string) value; If (valueString! = Null & amp; amp;; valueString.Length == MyLength) {new validation returns (actual, empty); } New Validation Return Return (Wrong, "Invalid Value"); }}  

and XAM:

   & Lt; /Binding.ValidationRules> & Lt; / Binding & gt;  

This work is fine but this requirement really is that I should not value the value in DB. The verifier should only have a red background.

I want to call the property's property when the value is not valid

edit

I want to call the Setter with this validity rule My property, when its length is not equal to 17 (MyLength).

I did this differently, I implement the IDataErrorInfo interface and apply its members :

  public string this [string columnName] {get {return Validate (columnName); }} Public string error {received; Private set; } Public string valid (string propertyName) {string error = null; Switch (propertyname) {case "value": if (_value.Length! = 17) error = "invalid value"; break; } Error = error; Return error; }  

and in binding, set flag:

  validated data eros = "true"  

now working I wanted to


No comments:

Post a Comment