I need to read a string from each of the the first cells of SelectedItems of the DataGrid
foreach (var item in myDataGrid.SelectedItems)
{
if (item[0].ToString().Contains("Buy"))
{
containsBuy = true;
}
if (item[0].ToString().Contains("Sell"))
{
containsSell = true;
}
}
How can I cast myDataGrid.SelectedItems? It is IList and gives object. Is there any simple and similar way to do it as it is done for one selected row of a DataGrid:
var row = myDataGrid.SelectedItem as DataRowView;
Here I can easy access any cell – row[i].
Just change your
foreachloop to: