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.
Jason, I was just wondering if there was a fix for this if you are using the Office2007 Theme?
Thanks.
Hello,
To get this working with the Office 2010 Blue theme you can follow pretty much the same approach. However, rather than pulling out sections of the default style, you can make the changes directly to the Office2010Blue.XamComboEditor.xaml file.
To go over this in a little more detail, you have to add the ValidationStates VisualStateGroup to allow validation to work. These validation states toggle the visibility of the ValidationErrorElement border element, which you also have to add to the template, which is then displayed whenever a user puts the editor in to an invalid state.
I've attached a modified sample so you can see how this works. You should even be able to pull the modified Office2010Blue.XamComboEditor.xaml file out of my Theme folder and add it directly to your application. For reference, the modified sections can be found on lines 496 and 647.
Please let me know if I can be of any further assistance.
Thanks Jason, it worked.
Do you know, is this actually a "bug" or is this actually a customization that we'll have to make for future updates to the Silverlight Line of Business controls?
Thanks again.
Glad I could help!
As for if this is a bug, we've discussed this with the development team and they have determined that this styling should be included in the control. Development issue 66820 has been logged for this and assigned to one of our design guys to get this implemented.
I'm going to create a private case for you which I will use to provide you with more information about the development issue and will also enable you to be notified when a fix is released.
Great, thanks Jason, just got the case. It's working great now with your fix.
Thanks again for your help.