sarevok97
sarevok97

Reputation: 15

DataGridRow returns null

I dont have a clue why DataGridRow returns null:

datagrid.ItemsSource = itemsource;
DataGridRow row = (DataGridRow)datagrid.ItemContainerGenerator.ContainerFromItem(itemsource[i]);

Do you have any idea? xd

Upvotes: 0

Views: 685

Answers (1)

dhilmathy
dhilmathy

Reputation: 2868

You're trying to access the container immediately after setting the ItemsSource. The container is an UI element, let the grid complete it's loading and try accessing the container after that. Possibly try at grid loaded event.

Upvotes: 1

Related Questions