Why ItemContainerGenerator.ContainerFromIndex() returns null and how to avoid this behavior?

后端 未结 5 436
我在风中等你
我在风中等你 2020-12-06 16:31

I\'m using this snippet to analyze the rows I\'ve selected on a datagrid.

for (int i = 0; i < dgDetalle.Items.Count; i++)
{
    DataGridRow row = (DataGri         


        
5条回答
  •  心在旅途
    2020-12-06 17:18

    The DataGrid is virtualizing the items, the respective rows (i.e. containers) are only created when the row is in view.

    You could either turn off virtualization (which makes the first time loading very slow if you have many items, also the memory usage will be higher) or you just iterate over the data and check the values of the data objects' properties which should be bound to the data-grid. Usually you should not need the UI elements at all...

提交回复
热议问题