Validations Extensions Help

Nov 18, 2011 at 3:17 PM


I am using the MEFedMVVM framework and so far it is a really great. along with the core framework i am also using the ValidationsExtensions, which are workign fine, but there is one issue, for example i want a field to be required, and the user does not enter any information into it so the field's set method is not being called and so is the validation, i have used the other way like on saving using the code below to validate the fields.

DataValidationHandler<UserGroupModel> validationHandler = new DataValidationHandler<UserGroupModel>().
			DependsOn(() => CurrentUserGroup.GroupName);

if (!validationHandler.ValidateAll(CurrentUserGroup))
	m_messageBoxService.ShowError("Please fix all the issues before saving the record.");

In the UserGroupModel i have the property defined as
public string GroupName
			get { return m_groupName; }
				m_groupName = value;
				ValidateAndNotifyPropertyChanged(() => GroupName,
				PropertyValidation.Create(() => string.IsNullOrWhiteSpace(GroupName),"Group Name is Required."));

but even calling the ValidateAll does not validates the property and return true. Also the CurrentUserGroup.HasErrors returns false here.

Would you please help me to make sure that all the validations does got fired before saving the record.

Nov 22, 2011 at 7:05 AM

You have to call the ForceValidation so that it forces a fake property change and validation will kick in