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

后端 未结 5 431
我在风中等你
我在风中等你 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:00

    Use this subscription:

    TheListBox.ItemContainerGenerator.StatusChanged += (sender, e) =>
    {
      TheListBox.Dispatcher.Invoke(() =>
      {
         var TheOne = TheListBox.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
           if (TheOne != null)
             // Use The One
      });
    };
    

提交回复
热议问题