Question

We are using XamDataGrid in our WPF application. It works well, we added support in our application for IDataErrorInfo:

<igDP:FieldLayoutSettings AllowFieldMoving="No"
    AutoGenerateFields="False"
    SupportDataErrorInfo="RecordsAndCells" 
    DataErrorDisplayMode="ErrorIconAndHighlight" />

The binding on this datagrid goes to an ObservableCollection of an object Foo that implements IDataErrorInfo. We have data validation on individual properties, such as a Text property, which generate an error if a property is empty or had too many characters. This works great for update scenarios--the cell with the error is highlighted and a tooltip appears.

  <igDP:Field Name="Text"
      Label="{base:TextID _TextField}">
  </igDP:Field>

What we need to accomplish is a validation of the cell's value against the entire observable collection bound to the data source. So if the user typed in "Apple" in row 2 for the Text cell, but "Apple" already exists in row 10 Text cell, we generate an error condition that the user must correct before continuing.

How could we best accomplish this with XamDataGrid? We want to keep it clean so that object Foo only validates its own properties and doesn't know about the overall collection.

This article is very close, but I am not sure how to accomplish it with XamDataGrid: Validation of collection item against entire collection to prevent duplicates Could we pass the XamDataGrid Items collection to a custom validator?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top