Hi,
After setting a data grid control's items source, I want to access the data row for each item I've added. There are more columns in the grid than properties on the item, and I would like to set their values. After reading the documentation, I tried the GetContainerFromItem method, but it returns null. My code looks like (with names simplified):
datagrid.ItemsSource = serviceCallResult[];
DataRow row;
foreach (item in datagrid.ItemsSource as serviceCallResult[])
{
row = datagrid.GetItemFromContainer(item) as DataRow;
...
}
The documentation said that every item in the grid has a container so this seems very odd, and my guess is that I made a mistake in providing data to the grid. Also, I did try to call the GetItemFromContainer method without the cast and just assign the result to a DependencyObject, and it was also null. Thanks in advance for any help.