I cant get the data validation to work with an unbound field. I have the SupportDataErrorInfo set to RecordsAndCells. I tested with text boxes and the data validation worked so I know it is not the object behind.
Any ideas? Is this possible?
Hello Aziz,
The issue here is more with using the XamComboEditor than it is the TemplateField. Some additional steps are needed with the SelectionChanged event of the ComboEditor and binding to it correctly.
I have attached a sample that demonstrates how this can be accomplished. A converter is used to bind the SelectedItems to the combo as an ObservableCollection<object>, which allows the Student to check the Subjects properly for validation.
If you have any further questions or concerns with this, please let me know.
XamDataGrid_IDataErrorInfoTemplateField.zip
Hello,
I have a similar problem with XamDataGrid and IDataErrorInfo support for TemplateField.
It highlights the error on the name but not on subjects. Can you please advise ?
Thanks
<dP:XamDataGrid DataSource="{Binding Path=Students}"> <dP:XamDataGrid.FieldLayoutSettings> <dP:FieldLayoutSettings SupportDataErrorInfo="RecordsAndCells" DataErrorDisplayMode="ErrorIconAndHighlight"/> </dP:XamDataGrid.FieldLayoutSettings> <dP:XamDataGrid.FieldLayouts> <dP:FieldLayout> <dP:Field Name="Name"/> <dP:TemplateField Name="Subjects" BindingType="UseAlternateBinding" AlternateBinding="{Binding Subjects}" Width="Auto"> <dP:TemplateField.DisplayTemplate> <DataTemplate> <ig:XamComboEditor Style="{StaticResource ComboBoxInCellStyle}" MaxWidth="150" AllowMultipleSelection="True" CheckBoxVisibility="Visible" ItemsSource="{Binding Path=AllSubjects}" SelectedItems="{Binding ., Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}" DisplayMemberPath="Label" > </ig:XamComboEditor> </DataTemplate> </dP:TemplateField.DisplayTemplate> </dP:TemplateField> </dP:FieldLayout> </dP:XamDataGrid.FieldLayouts> </dP:XamDataGrid>
public class Student : IDataErrorInfo, INotifyPropertyChanged { public string Name { get{return name;} set{ name = value; OnPropertyChanged(); } } public ObservableCollection<string> Subjects { get; set; } public string this[string columnName] { get { if (columnName == nameof(Name)) { if (string.IsNullOrEmpty(Name)) { return "Name cannot be empty"; } } if (columnName == nameof(Subjects)) { if (Subjects == null || !Subjects.Any()) { return "Subjects cannot be empty"; } } return string.Empty; } } public string Error { get { return string.Empty; } } }
I apologize that no one has yet answered this post. We were inundated with more posts than we had resources to cover. Since that time we have been adding people to the task of making sure every post gets a reply from an Infragistics employee.
I believe this may be the same issue as the following post:http://community.infragistics.com/forums/t/32325.aspx
The next service release for version 2010.2 should have this fix. To make sure you are notified of the bug fix, you can submit a bug report and leave a reference to these two posts in the report.
To report an issue you can use the following webpage:http://ko.infragistics.com/support/submitrequest.aspx
Thank you!