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

Nov 18, 2009 at 3:29 PM

Hi,

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,

Cristian

Nov 18, 2009 at 6:51 PM
Edited Nov 18, 2009 at 6: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

Cheers,
LT

 

 

 

 

Nov 18, 2009 at 7: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,

Cristian