I have a Datagrid with some columns. It is binded to a list of objects. One of the column is a text column: I need it as a "validation" column, infact I want that, for each row, the value of this cell is "OK" or "NOT OK", based on values present in other cells. I don't know how to write a string into a certain cell into the Datagrid. Any suggestion?
EDIT: following the class that describes the objects of DataGrid
public class BracketProperty
{
[XmlAttribute]
public int index { get; set; }
public BracketType type { get; set;}
public List<BracketPoint> bracketPointsList;
[XmlIgnore]
public String isPointSelectionEnded { get; set; }
}
EDIT2: someone tells me that this line of code is not good
this.BracketsDataGrid.ItemsSource = this.currentPropertyToShow.sides[this.sideIndex - 1].brackets;
where brackets
is defined as
public ObservableCollection<BracketProperty> brackets;
because is not a binding...how can I change it to be a binding?
The easiest way to do this is to create a data type class that has a public
property for each column in the DataGrid
. You should implement the INotifyPropertyChanged
interface in this class.
Then you can have a property which you could update in a PropertyChanged
handler:
private void YourDataType_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (Property1 == "SomeValue" && Property2 > 0) ValidationProperty = "OK";
else ValidationProperty = "NOT OK"; // Add your own condition above of course
}
In the constructor:
PropertyChanged += YourDataType_PropertyChanged;