I started a project using .NET 4.5, now I have to switch to .NET 4.0. Everything works fine, except the "Items"-Property of ItemContainerGenerator is missing. I use it to find the row of a DataGrid that starts with the letter of a typed key. The Code is:
ReadOnlyCollection<object> rows = datagrid.ItemContainerGenerator.Items;
datagrid.ScrollIntoView(rows[rows.Count - 1]);
foreach (DataRowView row in rows)
{
string name = row.Row.ItemArray[0].ToString();
if (name.StartsWith(keyChar + "", StringComparison.OrdinalIgnoreCase))
{
datagrid.ScrollIntoView(row);
datagrid.UpdateLayout();
return;
}
}
Note: When debugging, the "Items"-Property is present and filled.
Do you know a way to access the "Items"-Property or a workaround to get the same function without using the "Items"-Property? Any suggestions will be welcomed.
The ItemContainerGenerator.Items seems to be present in .NET 4.0: https://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid_properties(v=vs.100).aspx
.NET Framework 4 Other Versions
...
ItemContainerGenerator Gets the ItemContainerGenerator that is associated with the control. (Inherited from ItemsControl.)