I have a DataGrid and a string[][] dataSource array as a source data for this DataGrid. I use following code to set binding:
dataGrid.ItemsSource = dataSource;
for (int i = 0; i < columns; i++)
{
dataGrid.Columns.Add(new DataGridTextColumn
{
Binding = new Binding(string.Format("[{0}]", i))
});
}
How can I update an information in a cell of DataGrid when value in string[i][j] was changed?
If the data item that you are binding to implemented INotifyPropertyChanged then the update would happen automatically, as the data item/collection would broadcast that a property had been changed, and the datagrid would automatically be updated without you having to do a thing (manual grid rebinds can be slow depending on the amount of data).
So if you change the data structure that you are binding to from a string to something that implements INotifyPropertyChanged (even if you code up that data object yourself, which is easy to do), and set the grid to automatically generate columns, then all you will need to do is set the
dataGrid.ItemSourceproperty and update the individual data objects as necessary.