WPF DataGrid - how to set the row height for specific rows

Nov 18, 2009 at 2:29 PM


I was trying to set the row height for specific rows from code behind but I couldn't find how to do it.

I tried something like this: dataGrid1.Rows[0] = 25; (except there is no Rows collection).

Is there a way of doing this?

Thank you,


Nov 18, 2009 at 5:51 PM
Edited Nov 18, 2009 at 5:55 PM

Hi Cristian,

Your datagrid has an items collection so it would be datagrid1.Items.Item(0). 

Dim dgr As DataGridRow = TryCast(dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.Items.Item(0)), DataGridRow)
dgr.Height = 25






Nov 18, 2009 at 6:57 PM

Hi LT,

I was just about to post the solution I found when I saw you answered my question :)

DataGridRow someRow = dataGrid1.ItemContainerGenerator.ContainerFromIndex(1) as DataGridRow;
someRow.Height = 100;


Thank you,