Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get datagrid rows

How can I get the list of rows in the DataGrid? Not the bound items, but the DataGridRows list.

I need to control the visibility of these rows and it's only possible to control it as a DataGridRow and not as a data object.

Thanks!

like image 346
user196625 Avatar asked Oct 06 '12 17:10

user196625


1 Answers

You can get the row using ItemContainerGenerator. This should work -

for (int i = 0; i < dataGrid.Items.Count; i++)
{
    DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator
                                               .ContainerFromIndex(i);
}
like image 131
Rohit Vats Avatar answered Sep 20 '22 15:09

Rohit Vats