I am currently using data binding in my Windows Forms application.
I am taking the View Model approach which wraps all of my business functionality together. My data objects are Entity Framework POCOs which have all of the database metadata that includes maximum length, null etc. Each object implements the IDataErrorInfo interface. Entity Framework takes care of the field validation.
Now given that, I want to get the error messages into an UltraValidator. The only info I have is from 2009 on these forums which indicated that it did not support the interface. It would be great if it did although the IDataErrorInfo interface is not that great IMHO.
So my question is, I have lots of validation on different fields, what is the best way to do this.
So suppose I have a business object (without IDataErrorInfo and it implements INotifyPropertyChanged which is omitted):
public class MyPOCO
{
private string _name;
public string Name
get { return _name; }
set { _name = value; OnPropertyChanged("Name"); }
}
private int _age;
public int Age
get { return _age; }
set { _age = value; OnPropertyChanged("Age"); }
This is bound to a TextBox and a Numeric UpDown:
this.NameTextbox.DataBindings.Add("Text", this.ViewModel.MyPOCO, "Name", true, DataSourceUpdateMode.OnPropertyChanged ); this.Age.DataBindings.Add("Text", this.ViewModel.MyPOCO, "Age", true, DataSourceUpdateMode.OnPropertyChanged );
I want to add all kinds of validation I guess. This will be:
Do I need a single UltraValidator instance or do I need to add many instances? I am currently using:
this.EntityValidator.GetValidationSettings(this.NameTextbox).EmptyValueCriteria = Infragistics.Win.Misc.EmptyValueCriteria.NullOrEmptyString; this.EntityValidator.GetValidationSettings(this.NameTextbox).IsRequired = true; this.EntityValidator.GetValidationSettings(this.NameTextbox).DataType = typeof(string); this.EntityValidator.GetValidationSettings(this.NameTextbox).ValidationTrigger = Infragistics.Win.Misc.ValidationTrigger.OnValidating; this.EntityValidator.GetValidationSettings(this.NameTextbox).NotificationSettings.Caption = "My Validation"; this.EntityValidator.GetValidationSettings(this.NameTextbox).NotificationSettings.Action = Infragistics.Win.Misc.NotificationAction.Image; this.EntityValidator.GetValidationSettings(this.NameTextbox).NotificationSettings.Text = "The Name is required.";
Can you give me some examples here on how to achieve this please. I've looked at the legacy examples which are pretty basic. What condition classes are available?
The example uses a RangeCondition which derives from an Object.
Thanks,
Andez
Hi Andez,
I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
Hi Dimitar,
The supplied solution is what I was after. It works a treat. I thought I did respond to your solution but I guess not :/