Try setting the Validation. Template to {x:Null} if it shouldn't show the Validation Error StackPanel> Validate Value 1 Validate Value 2.
Try setting the Validation. Template to {x:Null} if it shouldn't show the Validation Error Validate Value 1 Validate Value 2.
That would not show the error on the UI, however, the page is still not valid which means I still can not fire the nextCommand because of the required field validation for the JobTitle property. – Bobby Aug 22 at 19:07 Can't you alter your IsValid code to only check validation on specific properties based on which RadioButton is checked? – Rachel Aug 22 at 19:11 That's how I currently have it.In my ValidationViewModelBase class I am inheriting the IDataErrorInfo and IValidationExceptionHandler.
I am filtering the validationAttribute list in the "this" method by adding or removing field validation based on the passed property name. However, this application has over 500 fields so the validation base class looks ugly at the moment. – Bobby Aug 22 at 19:23 @Bobby I'm not sure I understand what you mean.
Can you post a simplified bit of code showing your IDataError implementation? – Rachel Aug 22 at 19:39 I posted my code below, please take a look and let me know if you need more details. – Bobby Aug 22 at 21:42.
Sure, here is how my validationbase class looks like (Simplified) public class ValidationViewModelBase : ViewModelBase, IDataErrorInfo, IValidationExceptionHandler { private Dictionary> _propertyGetters; private Dictionary _validators; /// /// Gets the error message for the property with the given name. /// /// Name of the property public string thisstring propertyName { IList fieldsNames = new List(); { if (propertyName == "PresentlyEmployed") { //if its true then fieldsNames. Add("JobTitle"); AddFieldsValidation(fieldsNames); }else{ fieldsNames.
Add("EmploymentAddress"); RemoveValidation(fieldsNames); } if (this.propertyGetters. ContainsKey(propertyName)) { var propertyValue = this. PropertyGetterspropertyName(this); var errorMessages = this.
ValidatorspropertyName . Where(v =>!v. IsValid(propertyValue)) .
Select(v => v. ErrorMessage).ToArray(); return string. Join(Environment.
NewLine, errorMessages); } return string. Empty; } /// /// Gets an error message indicating what is wrong with this object. /// public string Error { get { var errors = from validator in this.
Validators from attribute in validator. Value where!attribute. IsValid(this.
PropertyGettersvalidator. Key(this)) select attribute. ErrorMessage; return string.
Join(Environment. NewLine, errors.ToArray()); } } } /// /// Gets the number of properties which have a validation attribute and are currently valid /// public int ValidPropertiesCount { get { var query = from validator in this. Validators where validator.Value.
All(attribute => attribute. IsValid(this. PropertyGettersvalidator.
Key(this))) select validator; var count = query.Count() - this. ValidationExceptionCount; return count; } } } /// /// Gets the number of properties which have a validation attribute /// public int TotalPropertiesWithValidationCount { get { return this.validators.Count(); } } public ValidationViewModelBase() { this. Validators = this.GetType() .GetProperties() .
Where(p => this. GetValidations(p). Length!
= 0) . ToDictionary(p => p. Name, p => this.
GetValidations(p)); this. PropertyGetters = this.GetType() .GetProperties() . Where(p => this.
GetValidations(p). Length! = 0) .
ToDictionary(p => p. Name, p => this. GetValueGetter(p)); } private ValidationAttribute GetValidations(PropertyInfo property) { return (ValidationAttribute)property.
GetCustomAttributes(typeof(ValidationAttribute), true); } private Func GetValueGetter(PropertyInfo property) { return new Func(viewmodel => property. GetValue(viewmodel, null)); } private int validationExceptionCount; public void ValidationExceptionsChanged(int count) { this. ValidationExceptionCount = count; this.
OnPropertyChanged("ValidPropertiesCount"); }.
Rachel: the above code is currently doing the job. However, I am not so proud of the way I am adding or removing fields. So I thought maybe DataTriggers can do the job for me.
If you have different approach please let me know. Thanks – Bobby Aug 22 at 20:18.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.