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 Jason,
I have the same problem and applied your templates in my app.xaml. The property bound to the combo editor has a [Required] attribute applied. When I clear the text, the red border appears, but when I select an item, the red border remains. My property setter is revalidating in both cases. I would like it to function the same as the textboxes which go back to their normal state once they have valid data.
Can you help me?
Thanks!
Jim
Nevermind - there was a problem in the validation routine. It's working correctly. Thanks.