Get datagrid rows

后端 未结 2 526
慢半拍i
慢半拍i 2021-01-02 02:50

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\'

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 03:02

    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);
    }
    

提交回复
热议问题