Hello
I am using XamComboEditor version 10.2.20102.1029, in a Silverlight 4.0 application under MVVM model.
XAML:
< ig:XamComboEditor Grid Row = "1" Grid Column = "1" Margin ="3" IsEditable = "True" AllowFiltering = "True" AutoComplete = "True" P:System.Windows.controls.ItemsControl.DisplayMemberPath = "Descripcion" ItemsSource = "{Binding Path = UnidadesMedidaIndependiente}" SelectedItem = "{Binding Path = UnidadMedidaIndependiente, Mode = TwoWay, NotifyOnValidationError = true, ValidatesOnExceptions = true}" / >
ViewModel: (implements InotifyPropertyChanged and INotifyDataErrorInfo).
[Required]
public Proxy.UnidadMedidaEntity UnidadMedidaIndependiente
{
get {return this.Independiente.UnidadMedida;}
set
ClearErrorFromProperty ("UnidadMedidaIndependiente");
If (value == null)
AddErrorForProperty ("UnidadMedidaIndependiente")
new ErrorInfo
P:System.Web.TraceContextRecord.IsWarning = false,
ErrorMessage = "you must select a unit of measure"
});
}
else if (this.Independiente.UnidadMedida! = value)
ValidateProperty("UnidadMedidaIndependiente",_value);
this.Independiente.UnidadMedida = value;
OnPropertyChanged ("UnidadMedidaIndependiente");
At start state the "UnidadMedidaIndependiente" property has the value null. If not selection is made and sent to save, it runs the method "base.ValidateEntity ()", which reported that the property is empty and must be marked as erroneous, but XamComboEditor control does not change the border color to red, or displays the ToolTip with the error message.
This same strategy works us with other controls, for example, the TextBox and the standard ComboBox.
Could you help us to identify the cause of this problem?
Thank you.
Jaimir G.
Hello Jaimir,
To display the validation errors the XamComboEditor needs to be re-templated to add a ValidationStates VisualStateGroup as well as adding the controls to display the validation errors and tooltip. You can pull this information from the default styles of the other XamEditors controls and place it in the default style of the XamComboEditor.
I have attached a sample that demonstrates and has this logic set up. I've placed the relevant styles in the App.xaml file.
Please let me know if you have any further questions or concerns about this matter.
Hi , I am working on validation for XamComboEditor. Your sample is working for typing in XamComboEditor.
I have a case as this:
A form has many fields, say some textbox, 5 XamComboEditors which are mandatory items. The form is bound to a ViewModel. When use input for textbox and hit submit button to submit data, I want to redbox showing up for XamComboEditors because user input nothing for those. But actually, no redbox showing up for those XamComboEditors.
How to resolve this problem?
Hello,
If the values are initially null and must be set by the user you can add errors for each null field when the ViewModel is created then the user will have to set values in order to clear the errors.
Sincerely,
Valerie
Developer Support Engineer
Infragistics
www.infragistics.com/support